✓ Accepted answer
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()
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()
print("ProximityPrompt triggered")
end)
1 comment
Another alternative is the change RunContext of a normal script to Client and it will act like a localscript