Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

1 comment

0

Maybe the beginning with the value....Have no idea since no error...

2 answers

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.