Ok... I know I asked this before... but I haven't figured it out yet so I need some help. When the TextButton is clicked, I need to find the name of the player who clicked the Button, then a Frame with the player's name will turn green. Here's the code I tried:
local Players = game:GetService("Players") local Player = Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent.PlayerStats[Player.Name].BackgroundColor3 = Color3.fromRGB(0, 255, 0) game.ReplicatedStorage.Values.PlayersReady.Value = game.ReplicatedStorage.Values.PlayersReady.Value +1 script.Parent.Visible = false end)
This is not a LocalScript and it is not working. Do I need to use some kind of RemoteEvent? Could use some help. Thanks.
You do game.Players.LocalPlayer or access the LocalPlayer using that in any way in a server script, you need to use a local script. Also, do you want the frame to show for everyone in the server or just the local player?
local Players = game:GetService("Players") Players.PlayerAdded:Connect(function( Player ) script.Parent.Parent.PlayerStats[Player.Name].BackgroundColor3 = Color3.fromRGB(0, 255,0) game.ReplicatedStorage.Values.PlayersReady.Value = game.ReplicatedStorage.Values.PlayersReady.Value +1 script.Parent.Visible = false end)
This should fix your issue if you're trying to do it on the server, if you're trying to hook it up to a UI click, you're gonna want to use YOUR code, but use a local script instead.
You can use a ClickDetector for your script.
local clickDetector = Instance.new('ClickDetector', script.Parent); clickDetector.MouseClick:connect(function(player) --what you want to happen end)
Also, I'm pretty sure that you can't do local Player = Players.LocalPlayer
if it's not in a local script.