I’m trying to change the Visible
property of my FrameGui when a ProximityPrompt (parented to an Attachment
in the workspace) is triggered. For over an hour, I’ve attempted solutions to no avail. Does anyone have their own solution? Do I need to provide more info? Thanks.
This is fairly easy to do.
Place a script inside your ProximityPrompt, and paste this inside:
--//Variables
local ProximityPrompt = script.Parent
--//Functions
ProximityPrompt.Triggered:Connect(function(player)
local PlayerGui = player.PlayerGui
PlayerGui.MyScreenGui.MyFrame.Visible = true
end)
Change the names as it appears in your explorer.
hmm, I see what I did wrong now. Didn’t pass player as a parameter
Thank you
Make sure you flag solutions with solution press that button
wanna gimme a minute first? Lol
new issue… so this works, but when I use a script to set Visible back to false, and then trigger the ProximityPrompt, it doesn’t set Visible to true.
That’s because you’re setting .Visible to false on the client correct?
To fix this,
-
Add a remote event into ReplicatedStorage and name it DisplayUI
-
Change the script to this:
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local DisplayUI = ReplicatedStorage.DisplayUI
local ProximityPrompt = script.Parent
--//Functions
ProximityPrompt.Triggered:Connect(function(player)
DisplayUI:FireClient(player)
end)
-
Add a new script into StarterPlayerScripts.
-
Paste this inside:
--//Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local Frame = PlayerGui:WaitForChild("ScreenGui"):WaitForChild("MyFrame")
local DisplayUI = ReplicatedStorage.DisplayUI
--//Functions
DisplayUI.OnClientEvent:Connect(function()
Frame.Visible = true
end)
yes, setting .Visible to false on the client. I actually tried using RemoteEvents in the server script parented to the ProximityPrompt before coming here for help. Hopefully this’ll work
this worked! Thank you for all the help. I hopefully won’t have to come back!
No problem. If you have any more questions, feel free to ask.