✓ Accepted answer
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.
local PS = game:GetService("Players")
script.Parent.Touched:Connect(function(hit)
local Player = PS:GetPlayerFromCharacter(hit.Parent)
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.
3 comments
Im sorry it did not work here what the output said: 08:49:42.598 - ScreenGui is not a valid member of PlayerGui 08:49:42.600 - Stack Begin 08:49:42.601 - Script 'Workspace.Part.Script', Line 9 08:49:42.601 - Stack End 08:49:42.712 - ScreenGui is not a valid member of PlayerGui 08:49:42.714 - Stack Begin 08:49:42.714 - Script 'Workspace.Part.Script', Line 9 08:49:42.715 - Stack End
i cecked it and it was there why isent it working ..anyways just ave the check :/
Well that error occurs when ScreenGui is not in the PlayerGui. Is the gui named ScreenGui? Does it exist when the player touches the part? If you are sure it is there then maybe you can use Player.PlayerGui:WaitForChild("ScreenGui").Frame.Visible = false instead.