Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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)
0
i dont think you should use a while loop inside the .Activated function. astronit 20 — 4y

Closed as Non-Descriptive by hiimgoodpack and maumaumaumaumaumua

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
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)

Ad