I want my GUI to pop up when I interact with the Proximity Script.
My GUI is not popping up on the first try when interacting with the proximity script. After multiple tries it will pop up though. Its sending the event, and its being received, but it won’t open the GUI. I couldn’t find anything on this online, so I am asking here.
this is the recieve event to open the gui
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
local Frame = script.Parent
Frame.AnchorPoint = Vector2.new(0.5, 0.5)
Frame.Position = UDim2.new(0.5, 0, -1, 0)
Frame.Visible = not Frame.Visible
wait(0.1)
Frame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0))
print('recieved')
end)
This is the code to send the event after the proximity prompt is triggered
local Event = game.ReplicatedStorage.RemoteEvent
local proximity = script.Parent.ProximityPrompt
script.Parent.ProximityPrompt.Triggered:connect(function(plr)
print('fired')
Event:FireClient(plr)
end)
1 Like
Are you receiving any errors in the output? I honestly don’t see any problem with the code you have provided, maybe the ScreenGui that the Frame is in could be disabled?
Try using this code for your local script:
local Frame = script.Parent
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
Frame.AnchorPoint = Vector2.new(0.5, 0.5)
Frame.Position = UDim2.new(0.5, 0, -1, 0)
if Frame.Visible then
Frame.Visible = false
else
Frame.Visible = true
end
task.wait(0.1)
Frame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0))
print('recieved')
end)
And try using this code for your server script:
local Event = game.ReplicatedStorage.RemoteEvent
local proximity = script.Parent.ProximityPrompt
script.Parent.ProximityPrompt.Triggered:Connect(function(plr)
print('fired')
if plr then
Event:FireClient(plr)
end
end)
proximity and gui should both be local? i dont see a point in an event?
also u should use playergui
Try :
local function openGui()
local Frame = script.Parent
Frame.AnchorPoint = Vector2.new(0.5, 0.5)
Frame.Position = UDim2.new(0.5, 0, -1, 0)
Frame.Visible = not Frame.Visible
wait(0.1)
Frame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0))
end
event.OnClientEvent:Connect(openGui)
I just tried this, and it didn’t fix my problem. It still makes me click it multiple times before opening.
Update: Another script was interfering with the script, so it was closing. My fault here.