The answer for this is Remote Events
Remote events are like small doors to the server to execute specific functions that will replicate across all the clients (otherwise, changes you make on your client will STAY on your client)
To fix this (in other words, what I'd do), you'd fire a Remote event to the server telling the server that the player clicked another player. The server would receive this and tell the player that you clicked to display the GUI.
First, you'd need to put a remote event in ReplicatedStorage called "PlayerClickedPlayer" and put this script in ServerScriptService:
2 | local replicatedStorage = game:GetService( "ReplicatedStorage" ) |
4 | replicatedStorage:WaitForChild( "PlayerClickedPlayer" ).OnServerEvent:Connect( function (player,subject) |
5 | game:GetService( "ReplicatedStorage" ):WaitForChild( "PlayerClickedPlayer" ):FireClient(subject) |
And this is your fixed code that you posted before (client script):
02 | local players = game:GetService( "Players" ) |
03 | local replicatedStorage = game:GetService( "ReplicatedStorage" ) |
05 | local player = players.LocalPlayer |
06 | local mouse = player:GetMouse() |
08 | mouse.Button 1 Down:Connect( function () |
09 | local player = players:GetPlayerFromCharacter(Mouse.Target.Parent) |
10 | if player and player.TeamColor.Name = = ( "Dirt brown" ) then |
11 | replicatedStorage:WaitForChild( "PlayerClickedPlayer" ):FireServer(player) |
15 | replicatedStorage:WaitForChild( "PlayerClickedPlayer" ).OnClientEvent:Connect( function () |
16 | player:WaitForChild( "PlayerGui" ).StartScreen.Frame.Visible = true |
(Also improved some things for you)
Hope this helps