The script is not activated after the ProximityPrompt trigger

Hello everyone! I wanted to create a mini test function to add addiction. But for some reason I used it
ProximityPrompt local script did not work.

image
LocalScript (ProximityPrompt):

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Boost = ReplicatedStorage:WaitForChild("RemoteBoost")
local ProximityPrompt = game.Workspace.TestBoost.ProximityPrompt

function boost(player)
	Boost:FireServer()
end
ProximityPrompt.Triggered:Connect(boost)

ServerScriptService Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteBoost")

 function Boost(Player)
	local DislikesBoost = Player:WaitForChild("leaderstats"):WaitForChild("DislikesBoost")
	
	DislikesBoost.Value += 0.5
end
remoteEvent.OnServerEvent:Connect(Boost)

Where did I make a mistake? :thinking:

ProximityPrompt.Triggered doesn’t work on local scripts.

Oh, how do I make FireServer () if this function only works on local script?

Is there a specific reason you want to do that locally, you can call ProximityPrompts from the server and ignore the remote events entirely

You can’t use Proximity on local script, you can use FireClient to fire event on Script and use OnClientEvent to trigger the Fire Event in Local Script

Im not gonna explain everything. But in server-side scripts, (which as just called “Script”), ProximityPrompt.Triggered event gives out a parameter which is the player that triggered the prompt’s instance. With this you can modify the player’s stats without having to use remote events.

So the server-side script should look like this:

function Boost(Player)
	local DislikesBoost = Player:WaitForChild("leaderstats"):WaitForChild("DislikesBoost")
	
	DislikesBoost.Value += 0.5
end
script.Parent.Triggered:Connect(boost)

(btw you cannot globally edit Values using local script so you can’t give yourself cash by only using a local script, only Scripts can give you cash)

2 Likes