Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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.

0
Instead of putting the script in the ProximityPrompt, put the script in the part. CoolBlueJay000 48 — 3y
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 CoolBlueJay000 48 — 3y
0
Sorry for being bad at explaining, I tried my best ¯\_(?)_/¯ CoolBlueJay000 48 — 3y

3 answers

Log in to vote
0
Answered by 3 years ago

The correct event is PromptTriggered, not Triggered.

0
ah thank you. MrBloxyPixel 4 — 3y
0
welp. i tried it and i got this error MrBloxyPixel 4 — 3y
0
PromptTriggered is not a valid member of ProximityPrompt "Workspace.shop man.Head.ProximityPrompt MrBloxyPixel 4 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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)
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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.

Answer this question