Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont this script (in a ProximityPrompt) work? its also in a local script

so i have this script where its suppose to open a Ui thats in the players uis. when i click the ProximityPrompt or press e it wont show the ui.

script.Parent.Triggered:Connect(function()
	game.Players.LocalPlayer.PlayerGui.Shop.Frame.Visible = true
end)

please help.

3 comments

0

Instead of putting the script in the ProximityPrompt, put the script in the part.

0

And then change the 1st part to "script.Parent.PROXIMITYNAMEHERE.Triggered:Connect(function()" (Also sorry for the seperate messages, I pressed enter accidently.) If that doesn't work, try doing a script instead of a LocalScript and put an argument in the top part. Then change the code in the 2nd line to "local Clone = script.PUTURGUIHERE:Clone()", Clone.Parent = player.PlayerGui

0

Sorry for being bad at explaining, I tried my best ¯_(?)_/¯

3 answers

The correct event is PromptTriggered, not Triggered.

3 comments

0

ah thank you.

0

welp. i tried it and i got this error

0

PromptTriggered is not a valid member of ProximityPrompt "Workspace.shop man.Head.ProximityPrompt

you can easily do a server script for this because the triggered function has a player parameter

script.Parent.Triggered:Connect(function(player)
	player.PlayerGui.Shop.Frame.Visible = true
end)

As far as I can tell from testing your code and my own, one good way of going about this is through the use of RemoteEvents. First we will be creating a Remote Event and putting it in Replicated Storage. Then it is as simple as firing this event from a server script,(the location does not matter as long as the server script knows what you mean by proximity prompt)and creating a local script wherever it works(starterplayer, workspace, etc) and making the frame visible from there

--Server Script

local rs = game:GetService("ReplicatedStorage")
local ppEvent = rs:WaitForChild("PPEvent")

script.Parent.Triggered:Connect(function()
	ppEvent:FireAllClients()
end)
--Local Script

local rs = game:GetService("ReplicatedStorage")
local ppEvent = rs:WaitForChild("PPEvent")
local players = game:GetService("Players") --or game.Players
local player = players.LocalPlayer
local shopGui = player.PlayerGui:WaitForChild("Shop")
local frame = shopGui:WaitForChild("Frame")

ppEvent.OnClientEvent:Connect(function()
	frame.Visible = true
end)

Be sure to accept this as your answer if it, is the correct solution of course.

This discussion is preserved as it was. New answers, comments, and votes are closed.