Trouble opening gui when proximity prompt is triggered

So i have been trying to open a gui when a proximity prompt is triggered, but when the proximity prompt is triggered it does nothing.

This is what i have tried so far.

local proximity_prompt = script.Parent 
local computer = game.Players.LocalPlayer.PlayerGui.computer.play.Visible

proximity_prompt.Triggered:Connect(function()	
	print("Proximity prompt triggered by player")
	computer = true	
end)

Also this is running in a local script

Since this script shows that the LocalScript is a child of the proximity prompt, I can assume that this is located somewhere in the Workspace. LocalScripts do not run in the workspace unless it’s parented to a players character. Either switch this to a normal script and use remote events, or try to put it in somewhere where the LocalScript works (StarterGui, StarterPlayer, ReplicatedStorage/First)

I say TRY because I’m not sure if events like Triggered work on LocalScripts

Yeah, after looking at some other topics I found that you cant use a local script on a proximity prompt and you can only use a normal script, so i have to change the script type.

also you are correct, you cant use triggered with local scripts

As stated above I could only get this to work when placing a localscript in StarterGui and doing the following.

local proximity_prompt = game:GetService("Workspace"):WaitForChild("Part"):WaitForChild("ProximityPrompt")
local computer = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Computer"):WaitForChild("Frame")


proximity_prompt.Triggered:Connect(function()	
	print("Proximity prompt triggered by player")
	computer.Visible = true	
end)

So i just found something on the toolbox and it had this code, but i changed to fit what i was using

local proximity_prompt = script.Parent 

proximity_prompt.Triggered:Connect(function(player)	
	player.PlayerGui.computer.play.Visible = true
end)

used in a normal script

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.