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

Something is wrong with my scripting, help?

Asked by 9 years ago
local i = 1

repeat print(i.." seconds left!")
    i = i + 1
    wait(1)
if i == 61 then
local pl = workspace:FindFirstChild("Player")
if pl then
    local hum = pl:FindFirstChild("Humanoid")
    if hum then
        hum.Health = 0
    end 
    end
     break end
until 
i == 61
0
What exactly is the problem you're having? User#9949 0 — 9y
0
It isn't killing the player, forgot to add that DarwinYork 85 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

There is an instant problem with your script. During the repeat, you're just printing 1 constantly.

You need a while loop.

Also, for the game.Players.LocalPlayer to work, you need to put this into a localscript.

Note that it kills the humanoid.

local i = 60
while i > 0 do -- goes through the loop until i is  0.
   print(i.." seconds left!")
   i = i - 1
end

if i == 0 then
local pl = game.Players.LocalPlayer
local character = pl.Character
if pl then
    local hum = pl:WaitForChild("Humanoid") -- Waiting until the humanoid is found.
    if hum then
        hum.Health = 0
    end 
   end


Note that you should only use break if you're in a while loop.

-- Hydroid18 (Using my alt until I can get help from the SH staff with my account.)

0
the timer doesn't even go off? DarwinYork 85 — 9y
0
fixed the timer part but it still doesn't kill the player DarwinYork 85 — 9y
0
Of course it's not going to work. You didn't really give enough information. Like what it is meant for and where it is located. TheNoobBoss1012 0 — 9y
0
It's pretty clear in the script: I just want the timer to go to count up to sixty and then kill the player. My timer worked but the killing part didn't, yet neither of yours worked which is why I unaccepted. DarwinYork 85 — 9y
Ad

Answer this question