Basically, I am trying to add a certain amount of “candies” which is a currency, to a certain player’s leaderstats. How would I achieve this?
I appreciate any help, and thank you in advance.
--// Client Script \\--
local player = game.Players.LocalPlayer
replicatedStorage.UpdateValue:FireServer(player, "Candies", 10)
--// Server Script \\--
local replicatedStorage = game:GetService("ReplicatedStorage")
replicatedStorage.UpdateValue.OnServerEvent:Connect(function(player, valueName, amount)
local playerName = game.Players:FindFirstChild(player.Name)
if valueName == "Candies" then
game.Players[playerName].leaderstats.Candies.Value += 1
end
game.Players[playerName].leaderstats.Candies.Value += 2
end)
I get this error: ServerScriptService.Script:8: invalid argument #2 (string expected, got Instance)
I also feel like there are other errors in my script, any help is appreciated.