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

[ANSWERED] How do I fix this script that doesn't work on player but works on studio?

So I am completely able to make this code work perfectly fine and nicely on Roblox studio but for some reason it won't work on Roblox player. I'm fairly new to all this but I tried my best to solve it and nothing I did worked. Please help.


script.Parent.ClickDetector.MouseHoverEnter:connect(function()
	script.Parent.Parent.Parent.DInfo.SurfaceGui.Dinfo.Visible = true
end)

script.Parent.ClickDetector.MouseHoverLeave:connect(function()
	script.Parent.Parent.Parent.DInfo.SurfaceGui.Dinfo.Visible = false
end)

script.Parent.ClickDetector.MouseClick:connect(function(click)
	local plr = game.Players.LocalPlayer.Name
	game.Players[plr].TeamColor = BrickColor.new("Really red")
	script.Parent.Parent.Parent.Done.SurfaceGui.TextButton.Visible = true				
end)

This is the code that works fine on studio. I have no clue what to do. What can I do to fix the problem? I am fully aware I can't do local player within a regular script, so what do I do then?

1 answer

script.Parent.ClickDetector.MouseClick:connect(function(click)
	local plr = game.Players.LocalPlayer.Name
	game.Players[plr].TeamColor = BrickColor.new("Really red")
	script.Parent.Parent.Parent.Done.SurfaceGui.TextButton.Visible = true              
end)

For the .MouseClick event, the first argument is the player who clicked. For example:

script.Parent.ClickDetector.MouseClick:connect(function(player)
	player.TeamColor = BrickColor.new("Really red")
	script.Parent.Parent.Parent.Done.SurfaceGui.TextButton.Visible = true              
end)

1 comment

0

Oh I see now. Thank you so much. You have been a great help!

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