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

Disable Enable not working? [SOLVED]

Asked by 10 years ago

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

Log in to vote
1
Answered by 10 years ago

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

0
What do you mean? Grenaderade 525 — 10y
0
How would I enable it if I did game.Players.LocalPlayer.PlayerGui or game.Players.LocalPlayer.Backpack? Grenaderade 525 — 10y
0
I've edited my answer. I have now provided some example code. TheGuyWithAShortName 673 — 10y
0
I just need the localscript edited, it doesn't make my character sit, it says Humanoid isn't a valid member of player. Grenaderade 525 — 10y
View all comments (3 more)
0
I did game.Players.LocalPlayer.Humanoid, but it says Humanoid isn't valid. Grenaderade 525 — 10y
0
Okay, I've edited my answer once more. TheGuyWithAShortName 673 — 10y
0
Yes! Thank you!! :D Grenaderade 525 — 10y
Ad

Answer this question