У меня есть скрипт, который должен давать 5 очков за каждое убийство. Однако при первом убийстве он дает 0 очков. На втором - 5, на третьем - 10 и т. Д. Я не могу понять, что является причиной этого.
Часть дробилки запускает событие, когда что-то умирает на нем. Затем он берется другим сценарием, чтобы дать очки, если кнопка дробилки использовалась во время убийства. https://youtu.be/06c4KFsvIzQ
- скрипт дробилки -
local debounce = false
script.Parent.Touched:Connect(function(OnTouched)
if not debounce then
debounce = true
local hum = OnTouched.Parent:FindFirstChild("Humanoid")
if hum ~= nil and hum.Health ~= 0 then
hum.Health = 0
script.GotKill:Fire()
end
debounce = false
end
end)
- скрипт кнопки -
local pos = script.Parent.Parent.Parent.Part.Position
local Crusher = script.Parent.Parent.Parent.Part
local wall1= script.Parent.Parent.Parent.bobbade
local wall2 = script.Parent.Parent.Parent.bebbade
local pos2 = script.Parent.Parent.Position
local debounce = false
script.Parent.MouseClick:Connect(function(Clicked)
if not debounce then
debounce = true
script.Parent.Parent.Position = pos2 - Vector3.new(0,0.5,0)
Crusher.Position = Crusher.Position - Vector3.new(0,1,0)
wall1.Position = wall1.Position - Vector3.new(0,1,0)
wall2.Position = wall2.Position - Vector3.new(0,1,0)
wait()
Crusher.Position = Crusher.Position - Vector3.new(0,1,0)
wall1.Position = wall1.Position - Vector3.new(0,1,0)
wall2.Position = wall2.Position - Vector3.new(0,1,0)
wait()
Crusher.Position = Crusher.Position - Vector3.new(0,1,0)
wall1.Position = wall1.Position - Vector3.new(0,1,0)
wall2.Position = wall2.Position - Vector3.new(0,1,0)
wait()
Crusher.Position = Crusher.Position - Vector3.new(0,1,0)
wall1.Position = wall1.Position - Vector3.new(0,1,0)
wall2.Position = wall2.Position - Vector3.new(0,1,0)
wait()
Crusher.Position = Crusher.Position - Vector3.new(0,1,0)
wall1.Position = wall1.Position - Vector3.new(0,1,0)
wall2.Position = wall2.Position - Vector3.new(0,1,0)
wait()
Crusher.Position = Crusher.Position - Vector3.new(0,1,0)
wall1.Position = wall1.Position - Vector3.new(0,1,0)
wall2.Position = wall2.Position - Vector3.new(0,1,0)
wait()
Crusher.Position = Crusher.Position - Vector3.new(0,1,0)
wall1.Position = wall1.Position - Vector3.new(0,1,0)
wall2.Position = wall2.Position - Vector3.new(0,1,0)
wait(1)
Crusher.Position = Crusher.Position + Vector3.new(0,1,0)
wall1.Position = wall1.Position + Vector3.new(0,1,0)
wall2.Position = wall2.Position + Vector3.new(0,1,0)
wait()
Crusher.Position = Crusher.Position + Vector3.new(0,1,0)
wall1.Position = wall1.Position + Vector3.new(0,1,0)
wall2.Position = wall2.Position + Vector3.new(0,1,0)
wait()
Crusher.Position = Crusher.Position + Vector3.new(0,1,0)
wall1.Position = wall1.Position + Vector3.new(0,1,0)
wall2.Position = wall2.Position + Vector3.new(0,1,0)
wait()
Crusher.Position = Crusher.Position + Vector3.new(0,1,0)
wall1.Position = wall1.Position + Vector3.new(0,1,0)
wall2.Position = wall2.Position + Vector3.new(0,1,0)
wait()
Crusher.Position = Crusher.Position + Vector3.new(0,1,0)
wall1.Position = wall1.Position + Vector3.new(0,1,0)
wall2.Position = wall2.Position + Vector3.new(0,1,0)
wait()
Crusher.Position = Crusher.Position + Vector3.new(0,1,0)
wall1.Position = wall1.Position + Vector3.new(0,1,0)
wall2.Position = wall2.Position + Vector3.new(0,1,0)
wait()
Crusher.Position = Crusher.Position + Vector3.new(0,1,0)
wall1.Position = wall1.Position + Vector3.new(0,1,0)
wall2.Position = wall2.Position + Vector3.new(0,1,0)
script.Parent.Parent.Position = pos2
script.Parent.Parent.Parent.Part.Script.GotKill.Event:Connect(function(OnKill)
Clicked.leaderstats.Gold.Value = Clicked.leaderstats.Gold.Value + 5
end)
debounce = false
end
end)