Okay so i have a glowing yellow brick and if u touch it a frame should like pop up just like quests are made right look
script.Parent.Touched:connect(function(hit) game.StarterGui.ScreenGui.Frame.Visible = false game.StarterGui.Successpartone.Frame.Visible = true end)
Your current attempt does not work because you are trying to access the player's GUI through the StarterGui
. You need access it through PlayerGui
, which is parented under the Player
instance.
In your Touched
event, you need to check if the part touching belongs to the player's character. We can use the Players:GetPlayerFromCharacter()
function to get the player that is touching the part. It returns the corresponding player instance or nil if it cannot find the player from the character. From here, we can access the player's PlayerGui.
--Get the player service. local PS = game:GetService("Players") script.Parent.Touched:Connect(function(hit) --Get the player from the character. local Player = PS:GetPlayerFromCharacter(hit.Parent) --If the player exists then change the visibility of the player's gui. if Player then Player.PlayerGui.ScreenGui.Frame.Visible = false Player.PlayerGui.Successpartone.Frame.Visible = true end end)
Make sure it is a Script
and not a LocalScript
. Parent it under the brick.
Please accept the answer if this helps.
u have to get the gui trough the player
local plr = game:GetService("Players").LocalPlayer game.workspace.part.Touched:Connect(function(hit) -- dont usee :connect its deprecated plr.PlayerGui.ScreenGui.Frame.Visible = false plr.PlayerGui.Successpartone.Frame.Visible = true end)