Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does a occupant script only change brick values and not gui values?

I have a script in a seat that when a player sits in it a gui is supposed to appear. I tested it with a transparency value and it worked, but not changing the visible property of a gui..


local seat = script.Parent
seat.Changed:connect(function(property)
	if property ~= 'Occupant' then return end
	
	local occupant = seat.Occupant
	if occupant then
		script.Parent.Transparency = 1
		game.StarterGui.ScreenGui.Frame.Visible = true
		game.StarterGui.ScreenGui.Frame.Next.Visible = true
		game.StarterGui.ScreenGui.Frame.Prev.Visible = true
	

	end
end)

1 answer

game.StarterGui would be incorrect, as it would be targeting the GUI that players get when they restart or die.

Instead, game.Players.PlayerNameHere.PlayerGui would be correct, as it would be targeting? that player.


local seat = script.Parent
seat.Touched:connect(function(character)
    if character.Parent:FindFirstChild("Humanoid") then
  	  local player = game.Players:GetPlayerFromCharacter(character.Parent)
  	  if player then
    		 script.Parent.Transparency = 1
       		 player.PlayerGui.ScreenGui.Frame.Visible = true
       		 player.PlayerGui.ScreenGui.Frame.Next.Visible = true
      		 player.PlayerGui.ScreenGui.Frame.Prev.Visible = true
	end
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.