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

Works in studio, but not in-game, help?

Asked by 9 years ago
function kill(part)
    local h = part.Parent:findFirstChild("Humanoid")
    if h then
        wait(.1)
        h.WalkSpeed = 0
        local a = Instance.new("Part")
        a.Parent = game.Workspace
        a.CFrame = h.Parent.Torso.CFrame+Vector3.new(0,1,0)
        a.CanCollide = false
        a.Size = Vector3.new(5,7,5)
        a.Anchored = true
        a.BrickColor = BrickColor.Blue()
        a.Transparency = .5
        a.Reflectance = .5
        a.TopSurface = "Smooth"
        a.BottomSurface = "Smooth"
        game.Players.LocalPlayer.Character.Humanoid.Changed:connect(function(jumpy) if jumpy == "Jump" then game.Players.LocalPlayer.Character.Humanoid.Jump = false end end
        )h.Parent.Torso.Anchored = false
        for i = 1,110 do
            wait()
            h.Health = h.Health - 1
            h.Parent.Health.Disabled = true
        end
        if h.Health == 0 then
            wait(5)
            a:Destroy()
        end
    end
end

script.Parent.Touched:connect(kill)

When you touch it, it is supposed to insert a new part, that looks like ice and slowly kill you. It does everything in-game just not the killing part, which means the player can not move until he/she resets. Help? Also when you die, it inserts new parts... how do I prevent that from happening?

0
I made it a local script, but it now doesn't work at all Senor_Chung 210 — 9y

3 answers

Log in to vote
0
Answered by 9 years ago

If you're not already, make sure this is in a LocalScript, it's accessing the LocalPlayer.

Ad
Log in to vote
0
Answered by 9 years ago

Pretty much what he teamkilled said; In studio you are both Client and Server, unlike in-game.

Log in to vote
0
Answered by
Gamenew09 180
9 years ago

Replace game.Players.LocalPlayer.Character.Humanoid with h.

Answer this question