You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
making a weight that adds to the players strength value (in leaderstats), such an original idea, right?
-
What is the issue? Include screenshots / videos if possible!
when i click the tool, it doesn’t add to the leaderstats, and it gives me an error.
the error:

-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i have tried looking on the developer hub on changing values using leaderstats, but nothing happened.
my code:
this is a local script, in a tool.
script.Parent.Activated:Connect(function()
script.Parent.Lift:FireServer()
end)
and this is a server script.
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local strength = Instance.new("IntValue",leaderstats)
strength.Name = "Strength"
end)
game.StarterPack.Weight.Lift.OnServerEvent:Connect(function(player)
player.leaderstats.strength.Value = player.leaderstats.strength.Value + 1
end)
thanks for reading, any help is apreciated.
ps. the remote event is inside a tool called “Weight”.
strength
should be Strength
, capitalization is key.
Also, to make your thing a bit simpler, change
player.leaderstats.strength.Value = player.leaderstats.strength.Value + 1
To
player.leaderstats.Strength.Value += 1
1 Like
which script do i change the capitlization in?
The line in your OnServerEvent
game.StarterPack.Weight.Lift.OnServerEvent:Connect(function(player)
player.leaderstats.strength.Value = player.leaderstats.strength.Value + 1
end)
Should be
game.StarterPack.Weight.Lift.OnServerEvent:Connect(function(player)
player.leaderstats.Strength.Value += 1
end)
1 Like
doesn’t work for some reason…
Are you getting any errors or anything?
Okay I must’ve not waken up yet and didn’t realise the StarterPack remote, thanks for that @ProBaturay!
2 Likes
It is because you are using the StarterPack folder. It is not firing the RemoteEvent in the StarterPack folder. You may move the RemoteEvent
to ReplicatedStorage.
game:GetService("ReplicatedStorage").Weight:FireServer()
And then
game:GetService("ReplicatedStorage").Weight.OnServerEvent:Connect(function(player)
end)
2 Likes
It won’t work because you set the name as “Strength” but later you’re trying to find “strength”. Make sure you have a capital S.
1 Like
Thanks everyone it works fine now. Have a good day!
3 Likes