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

How do i loop this script?

Asked by 8 years ago
wait(1)
game.Players.LocalPlayer.Character.Stun=Remove()
wait()
game.Players.LocalPlayer.Character.Stun=Remove()

Any ideas guys? also it doesnt delete the following "Stun" can some one tell me what is the right code for it?

0
Can you add some more info. e.g what is stun and why you need this in a loop. User#5423 17 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

You're using functions wrong.

To use the Remove function, you use : after the thing you want to Remove.

Don't use Remove.

Remove is deprecated, and you should be using Destroy().

wait(1)
game.Players.LocalPlayer.Character.Stun:Destroy()
wait()
game.Players.LocalPlayer.Character.Stun:Destroy()

Make sure you're using a Local Script.

Only Local Scripts can access Local Player.

-- Inside a Local Script
wait(1)
game.Players.LocalPlayer.Character.Stun:Destroy()
wait()
game.Players.LocalPlayer.Character.Stun:Destroy()

Both of these lines of code do the same thing.

If you want to continuously Destroy the Stun, use a while loop.

while wait(0.1) do
    game.Players.LocalPlayer.Character.Stun:Destroy()
end

Also, use variables,

-- Local Script in StarterPack or StarterGui
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local Stun = char:WaitForChild("Stun")-- edit

while wait(0.1) do
    Stun:Destroy()
end
This script could also be placed elsewhere , but I would suggest not doing this.
  • Side Note,

I don't like using loops, and there's probably a better way of solving your problem, but you gave no context, sorry.

Hope I helped.

Good Luck!

If I did help, don't forget to accept my answer.
0
Edited my code to fix some errors. User#11440 120 — 8y
Ad

Answer this question