Hello, i am unable to add points using remote events.
(Server) Script for the event :
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local givepcvalue = ReplicatedStorage:WaitForChild("GivePC")
local function givepc(player)
local stat = player.leaderstats.PCs.Value
print(player.Name .. " fired the remote event")
stat = stat + 1
end
-- Call "onCreatePart()" when the client fires the remote event
givepcvalue.OnServerEvent:Connect(givepc)
(Server) Script that fires the event :
script.Parent.Triggered:Connect(function(plr)
game.ReplicatedStorage.GivePC:FireClient(plr)
script.Parent.Parent.Parent.Parent:Destroy()
end)
(it detects if the proximity prompt has been triggered)
There is no errors in the output and the part correctly gets deleted.
(Server) Script for the leaderstats (if needed) :
game.Players.PlayerAdded:connect(function(p)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
stats.Parent = p
local money = Instance.new("IntValue")
money.Name = "Coins"
money.Value = 0
money.Parent = stats
local money = Instance.new("IntValue")
money.Name = "Gems"
money.Value = 0
money.Parent = stats
local money = Instance.new("IntValue")
money.Name = "PCs"
money.Value = 0
money.Parent = stats
end)

1 comment
Attempt to connect failed: Passed value is not a function (line 11)