I made a simple GUI that is a GUI with a frame in it with text buttons "Police" and "Criminals". Within each button is a code:
local plr = script.Parent.Parent.Parent.Parent.Parent.Name
script.Parent.MouseButton1Click:Connect(function()
game.Player[plr].Teamcolor = BrickColor.new("Bright orange")
game.Workspace[plr].Humanoid.Health = "0"
script.Parent.Parent.Parent.Enabled = false
end)
It isn't working, why, none of the things are underlined yet it still doesn't work. Hmm

2 comments
maybe you used to many Parents in your script? Carefully check your code and make sure the Parents all line up to the correct thing.
if its a local script, get your player by using 'gameGetService("Players").LocalPlayer' And it SHOULD be a local script anyway for use in PlayerGui, as Server Scripts will not run in PlayerGui