I am using a regular server script, which it can not get the users playerID.
script.Parent.MouseButton1Click:Connect(function(Player) local playerId = Player.UserId script.Parent.Parent.No1.Value:WaitForChild('Eng').P1.Disabled = false wait(2) script.Parent.Parent.No1.Value:WaitForChild('Eng').P1.Disabled = true script.Parent.Parent.No1.Value:WaitForChild('Eng').P2.Disabled = false wait(2) script.Parent.Parent.No1.Value:WaitForChild('Eng').P2.Disabled = true script.Parent.Parent.No1.Value:WaitForChild('Eng').P3.Disabled = false wait(2) script.Parent.Parent.No1.Value:WaitForChild('Eng').P3.Disabled = true script.Parent.Parent.No1.Value:WaitForChild('Eng').P4.Disabled = false wait(2) script.Parent.Parent.No1.Value:WaitForChild('Eng').P4.Disabled = true script.Parent.Parent.No1.Value:WaitForChild('Eng').P5.Disabled = false wait(2) script.Parent.Parent.No1.Value:WaitForChild('Eng').P5.Disabled = true script.Parent.Parent.No1.Value:WaitForChild('Eng').P6.Disabled = false script.Parent.Parent.Confirm.BackgroundColor3 = Color3.new(0, 255, 0)
In the developer console it was saying "attempt to index local 'Player' (a nil value)
local player = game.Players.LocalPlayer local ID = player.UserId script.Parent.MouseButton1Click:Connect(function() print(ID) script.Parent.Parent.No1.Value:WaitForChild('Eng').P1.Disabled = false wait(2) script.Parent.Parent.No1.Value:WaitForChild('Eng').P1.Disabled = true script.Parent.Parent.No1.Value:WaitForChild('Eng').P2.Disabled = false wait(2) script.Parent.Parent.No1.Value:WaitForChild('Eng').P2.Disabled = true script.Parent.Parent.No1.Value:WaitForChild('Eng').P3.Disabled = false wait(2) script.Parent.Parent.No1.Value:WaitForChild('Eng').P3.Disabled = true script.Parent.Parent.No1.Value:WaitForChild('Eng').P4.Disabled = false wait(2) script.Parent.Parent.No1.Value:WaitForChild('Eng').P4.Disabled = true script.Parent.Parent.No1.Value:WaitForChild('Eng').P5.Disabled = false wait(2) script.Parent.Parent.No1.Value:WaitForChild('Eng').P5.Disabled = true script.Parent.Parent.No1.Value:WaitForChild('Eng').P6.Disabled = false script.Parent.Parent.Confirm.BackgroundColor3 = Color3.new(0, 255, 0)
If I understand you correctly, you wanna know the ID of a player.
This is also a localscript, if you wish to do anything on the server, use a remoteevent.
What I did was refer to the ID of the player, which is the localplayer. And print it everytime they click the GUI
Also, you can use GetUserIdFromNameAsync if you really wanna do it from the server side, but it's gonna be harder.
You are using a gui. Guis do not have any way of getting the player as they are supposed to be manage by LocalScript
s, which can access game.Players.LocalPlayer
. Use a remote event.
LocalScript
(Parented to gui button):
script.Parent.MouseButton1Click:Connect(function() local remoteEvent = game.ReplicatedStorage.RemoteEvent -- Make a remote event and reference it here remoteEvent:FireServer(script.Parent) end)
ServerScript
(Parented to gui button):
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, gui) -- Reference same remote event local playerId = player.UserId -- Type the rest of the code here (replace every script.Parent with gui) end)