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.
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)
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)