Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I fix this damage script for a laser gun?

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

0

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

1 answer

script.Parent.Activated:Connect(function()
    script.Parent.Handle.Beam.Enabled = true
    script.Parent.Handle.Fire:Play()
        zombie.Humanoid.Health = zombie.Humanoid.Health - 150
        wait(.1625)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.