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

Regen script not working? [I need answers please!]

Asked by 10 years ago
m = script.Parent
r = script.res
c = m:Clone()
local gui =  script.Parent.sur:Clone()
function t()
    if r.Value == false then
        gui.Parent = game.Players.LocalPlayer.PlayerGui
    wait(1)
    script.Disabled = true
    m:remove()
    r.Value = true
    wait(6)
    script.Disabled = false
    m = m:Clone()
    m.Parent = game.Workspace
    m:makeJoints()
    r.Value = false
    end
end
m.Touched:connect(t)

Basically, when a player touches the model, the model removes and inserts a gui into the Player's gui. Then, after 6 seconds, the model appears again for another player to touch. There are no errors in the Developer Console, but the script wont work.

0
Maybe the beginning with the value....Have no idea since no error... Adryin 120 — 10y

2 answers

Log in to vote
1
Answered by
iaz3 190
10 years ago

The problem is you are using a localscript. game.Players.LocalPlayer is only for local scripts, but local scripts only run in the player's character, backpack, or PlayerGui

You will need to use a script, and get the player from the character

Use :GetPlayerFromCharacter

Ad
Log in to vote
1
Answered by
Merely 2122 Moderation Voter Community Moderator
10 years ago

Setting script.Disabled = true is going to stop the running script. It's never going to re-enable itself on line 13.

Answer this question