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

Why does Script in ScreenGui wont Enable executed from the Workspace?

So here guys, I have a problem with this script in Model :

function onClicked(theplayer)
	script.Parent.play:Play()	
    h = theplayer.Character:FindFirstChild("Humanoid")
    h.WalkSpeed = 21
	game.StarterGui.AddedRedbull.Script.Disabled = false
    script.Parent.Parent.Parent.REDBULL1:Destroy()
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

As written below, it says (game.ScreenGui.AddedRedbull.Script.Disabed = false) so when I click on item, it wont enable the script in ScreenGui... Please if you know the answer write it down! Thanks for any help!

1 answer

✓ Accepted answer

Hey, so the problem you have here is that you're trying to access the ScreenGui through the game, when it needs to go through the PlayerGui first.

Please note that for this to work, it has to be in a script inside of something that contains the ClickDetector you should have already.

function onClicked(theplayer)
    script.Parent.play:Play()   
    local h = theplayer.Character:FindFirstChild("Humanoid")
    h.WalkSpeed = 21
    theplayer.PlayerGui.ScreenGui.AddedRedbull.Script.Disabled = false
    script.Parent.Parent.Parent.REDBULL1:Destroy()
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

If this script doesn't work then I would need more information such as the name and location of everything in your GUI. Let me know if it works!

Also for efficiency, localize the variable "h". (Optional)

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