I am trying to create a laser gun which damages a zombie. For some reason, the code I used didn't work. Please help.
local zombie = workspace.Zombie
script.Parent.Activated:Connect(function()
script.Parent.Handle.Beam.Enabled = true
script.Parent.Handle.Fire:Play()
while script.Parent.Activated == true do
zombie.Humanoid.Health = zombie.Humanoid.Health - 150
wait(.1625)
end
end)
script.Parent.Deactivated:Connect(function()
script.Parent.Handle.Beam.Enabled = false
script.Parent.Handle.Fire:Stop()
end)

1 comment
i dont think you should use a while loop inside the .Activated function.