My script is supposed to make things inside a GUI active so that players can see if they won/lost the game.
The giving of XP works, but for some reason, the game won't access PlayerGui (Is it even possible to access in the first place?)
Everything is named correctly
Can someone please help me? Here's the script:
function EndGame() local player = game.Players:getPlayers() for i = 1, #player do if player[i].TeamColor == BrickColor.new("Bright green") then player[i].PlayerGui.EndGameGUI.Frame.Victory.Visible = true player[i].Other.XP.Value = player[i].Other.XP.Value + 300 elseif player[i].TeamColor == BrickColor.new("Bright red") then player[i].PlayerGui.EndGameGUI.Frame.Defeat.Visible = true player[i].Other.XP.Value = player[i].Other.XP.Value + 150 end end end
If you have the FilteringEnabled property in the workspace set to true, then the server will not be able to access the player's PlayerGui. When this property is set to true, the playergui will not replicate to the server and only the client will have access to it. If you want to access it then you should either turn off FilteringEnabled (wouldn't recommend) or use remote events to communicate with the client and change their playerguis.
Example: Create a remote event in replicatedstorage
--Server Script local event = game:GetService'ReplicatedStorage':WaitForChild'RemoteEvent' function EndGame() event:FireAllClients("end") end --Local Script local event = game:GetService'ReplicatedStorage':WaitForChild'RemoteEvent' repeat wait() until game.Players.LocalPlayer local player = game.Players.LocalPlayer event.OnClientEvent:connect(function(arg) if arg == "end" then if player.TeamColor == BrickColor.new("Bright green") then player.PlayerGui.EndGameGUI.Frame.Victory.Visible = true player.Other.XP.Value = player.Other.XP.Value + 300 elseif player.TeamColor == BrickColor.new("Bright red") then player.PlayerGui.EndGameGUI.Frame.Defeat.Visible = true player.Other.XP.Value = player.Other.XP.Value + 150 end end end