0

Why doesnt localscripts work on proximity prompts?

doesnt work, really strange.

script.Parent.Triggered:Connect(function()
print("Test")
end)


nothing outputs the local script is inside of the proximity prompt, i tried using remote events but when i do OnClientEvent (yes i called it through a regular script) nothing happens again. Its really frustrating. Nothing works

1
Edited 1 month ago

It's important to know that LocalScripts cannot run in workspace. Instead, you need to use a regular script and RemoteEvents.

For example, in the ProximityPrompt under workspace you would use a regular script with something like this:

script.Parent.Triggered:Connect(function(plr)
game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent"):FireClient(plr)
end)


Note: You will need to have a RemoteEvent in ReplicatedStorage

Then in a LocalScript which I would put in StarterPlayerScripts you would write something like this:

game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent").OnClientEvent:Connect(function()
-- Whatever you want to happen
print("ProximityPrompt triggered")
end)


Alternatively

You can just reference the proximity prompt from a LocalScript in StarterPlayerScripts (or another place where LocalScripts work)

This would look something like:

game.workspace.Part:WaitForChild("ProximityPrompt").Triggered:Connect(function()
-- Whatever you want to happen
print("ProximityPrompt triggered")
end)

0
Another alternative is the change RunContext of a normal script to Client and it will act like a localscript T3_MasterGamer 2127 — 1mo