ProximityPrompt won’t open GUI:
script.Parent.Triggered:Connect(function()
game.StarterGui.ROSPACE.Frame.Visible = true
end)
I also tried with game.Players.LocalPlayer.PlayerGui.ROSPACE.Frame.Visible but it still doesn’t work
ProximityPrompt won’t open GUI:
script.Parent.Triggered:Connect(function()
game.StarterGui.ROSPACE.Frame.Visible = true
end)
I also tried with game.Players.LocalPlayer.PlayerGui.ROSPACE.Frame.Visible but it still doesn’t work
You can’t toggle a GUI in StarterGui.
Try:
script.Parent.Triggered:Connect(function(p)
p.PlayerGui.ROSPACE.Frame.Visible = true
end)
Also, is this in a serverscript or localscript?
LocalScript, I tried the script you gave me still doesn’t work
I forgot to add the ROSPACE. Try it now.
I already did that myself, yet didn’t work
I think it’s worth mentioning that the player’s avatar is a custom StarterCharacter though I don’t think that’s the problem since it didn’t work even without a custom StarterCharacter
If you want to use a ProximityPrompt from a LocalScript, it will need to be in startergui. Here’s an example once you’ve parented the script to StarterGui:
workspace.Part.ProximityPrompt.Triggered:Connect(function(player)
player.PlayerGui.ROSPACE.Frame.Visible = true
end)
Hope this helps!
Put this script into starter GUI and reroute the script to look for the GUI in it’s pathway
The Triggered event of ProximityPrompt instances is not valid for local scripts, this will need to be handled by a server script.
local Prompt = script.Parent
Prompt.Triggered:Connect(function(Player)
Player.PlayerGui.ROSPACE.Frame.Visible = true
end)
Should be as simple as this (server script inside the prompt), regarding all of the GuiObjects have been correctly referenced in the provided order.
Hey, I’ve marked this as a solution since it actually worked but I noticed that if I close the frame by clicking on a button inside the frame that makes the ROSPACE.Frame invisible I can’t reopen it by using the proximity prompt
That’s because the “Visible” property does not replicate across the client-server boundary, if you want a change to be visible from the client then you’ll need to make use of a RemoteEvent instance.
local Prompt = script.Parent
local Remote = game.ReplicatedStorage.RemoteEvent
Prompt.Triggered:Connect(function(Player)
Remote:FireClient(Player)
end)
Then on the client-side of things you’ll need a local script with a corresponding “OnClientEvent” handler which sets the value of the “Visible” property for the respective frame.
Oh my bad I messed up what I meant on the previous post, I’ve edited it now
Why don’t you add a local script inside the gui you want the proximity promt to open and then get the proximity promt from workspace so like something like this!
local proximity = game.Workspace. -- proximity name
proximity.Triggered -- blah blah blah
Because the ProximityPrompt is located in multiple models
Then loop so you could do something like this
for i,v in pairs (game.Workspace.proximitypromts:GetChildren()) do
v.Triggered:Connect(function() --blah blah blah
end
I am on mobile so there maybe errors
v
is a child of proximity prompt, not a property and nor does it have its event. A better way to do it is-
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA('ProximityPrompt') then
v.Triggered:Connect(function(player)
-- Insert Code Here
end)
end
end
Controlling a GUI through local script isn’t possible. You can use the player parameter and fire a remote event.
Server Script
script.Parent.Triggered:Connect(function(player)
game:GetService('ReplicatedStorage').RemoteEventName:FireClient(player)
end)
Local Script
game:GetService('ReplicatedStorage').RemoteEventName.OnClientEvent:Connect(function()
-- Put this script inside StarterGui
local ROSPACE = script.Parent.ROSPACE
ROSPACE.Frame.Visible = true
end)
It does work, but it only opens the GUI once
Try having the script inside the GUI you are trying to open
ProximityPrompt.triggered:Connect(function()
script.parent.Frame.Visible = true
end
The GUI needs to be parented to the part with the ProximityPrompt, and the prompt script needs to be in StarterGUI. This is how I’ve always done it and it works great clientside.
So for example, I’m not on my PC, but I will try to make it make sense here.
You should have the part with the ProximityPrompt. You will then move the GUI into that part as a child. From there you will place a LocalScript into StarterGui. It should look something similar to this:
Workspace:
Part
ProximityPrompt
Your GUI
LocalScript inside of StarterGui:
local gui = game.Workspace.PARTNAME
local prompt = game.Workspace.PARTNAME
prompt.ProximityPrompt.Triggered:Connect(function()
print("Prompt triggered!")
gui.YOURGUINAME:Clone().LocalPlayer.PlayerGui
print("Player has received GUI!")
end)
Make sure the GUI is visible so that you can make sure that it works
I am on cell, so excuse me for any mistakes, but this should work just fine.
Good luck!