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

Disable Enable not working? [SOLVED]

So, I'm trying to make a game where it makes you bounce up and down and see who wins, but the script isn't enabling the LocalScript. Here are both scripts:

Original Script:

message = game.Workspace.Message
while true do
	message.Text = "Starting new game..!"
	wait(5)
	message.Text = ""
	wait(5)
	message.Text = "Loading Map..."
	game.Lighting.Map:clone().Parent = Workspace
	wait(0.5)
	message.Text = "Building..."
	wait(0.5)
	message.Text = "Scripts enabling..."
	wait(0.5)
	message.Text = "Fixing..."
	wait(0.5)
	message.Text = "Spawning players..."
	wait(5)
	script.LocalScript.Disabled = false
	wait(3)
	script.LocalScript.Disabled = true
end

LocalScript:

wait(0.1)
game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(-11.8, 45.96, 12.8)
wait(0)
game.Players.LocalPlayer.Humanoid.Sit = true

Thank you!

1 answer

✓ Accepted answer

LocalScripts only run when they are parented to a child of the player (Their character, PlayerGui, or Backpack). You must parent the LocalScript to a child of each player and then enable it.

EDIT Here's some code that may help you out:

for i,v in next,Game:GetService("Players"):GetPlayers() do --loops through every player
local ls=script.LocalScript:Clone() --clones the local script
ls.Parent=v:WaitForChild("PlayerGui") --parents the local script to the player's playergui
ls.Disabled=false --enables the local script
end

EDIT2 Humanoid is a child of Character, not Player (I've also made some parts more efficient)

repeat wait(0.1) until Game.Players.LocalPlayer.Character
game.Players.LocalPlayer.Character:WaitForChild("Torso").CFrame = CFrame.new(-11.8, 45.96, 12.8)
wait(0)
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Sit = true

7 comments

0

What do you mean?

0

How would I enable it if I did game.Players.LocalPlayer.PlayerGui or game.Players.LocalPlayer.Backpack?

0

I've edited my answer. I have now provided some example code.

0

I just need the localscript edited, it doesn't make my character sit, it says Humanoid isn't a valid member of player.

0

I did game.Players.LocalPlayer.Humanoid, but it says Humanoid isn't valid.

0

Okay, I've edited my answer once more.

0

Yes! Thank you!! :D

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