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

This works in studio... yet when I play it in game it doesn't work! HELP?

enabled = false

function onTouched(hit)
wait(3)
game.Players.LocalPlayer.PlayerGui.paint.Frame.Visible = true
enabled = true
if enabled == false then
game.Players.LocalPlayer.PlayerGui.paint.Frame.Visible = false

end
end

script.Parent.Touched:connect(onTouched)

4 comments

0

is it a local script in startergui?

0

no... its a script in the brick. Say you want to get your car painted... You drive up and the gui shows up... the gui is in startergui. And the script i'm having trouble with is in the paintbrick <--- the otouched brick.

0

It works in studio because in Play mode the client and server are together meaning you can access the player with a server script, however when the game is played the server and client aren't together meaning a server script cant access the client. That's the simplest terms I can put it in...

1

Only local scrips have access to the LocalPlayer variable, server scripd do not. You will have yo use hit.Parent to try and find a player.

1 answer

Im a beginner but Imma try help. They might be wrong so no high hopes.

enabled = false

function onTouched(hit)
wait(3)
game.Players:FindFirstChild(hit.Parent.Name).PlayerGui.paint.Frame.Visible = true
enabled = true
if enabled == false then
game.Players:FindFirstChild(hit.Parent.Name).PlayerGui.paint.Frame.Visible = true

end
end

script.Parent.Touched:connect(onTouched)

otherwise try this??? Place GUI into this script. Make sure the GUI is visible Then also add in the X (or close) button???

local gui1 = script.paint

function onTouched(player)
	local newgui2 = gui1:Clone()
	newgui2.Parent = player.PlayerGui
end

script.Parent.Touched:connect(onTouched)

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