Im trying to make a kind of simulator where you get strenght by clicking on the screen while a tool is equipped. i have made a leaderstats script and it works as its supposed to. the error says it's on line 12 -Players.seikkatsu.Backpack.Saber.Saber equipped script:12: attempt to perform arithmetic on field 'Strenght' (a userdata value)
------------------< variables >---------------- local uis = game:GetService("UserInputService") local saber = script.Parent local p = game.Players.LocalPlayer local l = p.leaderstats ------------------< code >--------------------- saber.Equipped:Connect(function(hm) uis.InputBegan:Connect(function(input1) local mouse1 = input1.UserInputType if mouse1 == Enum.UserInputType.MouseButton1 then print("equipped") l.Strenght = l.Strenght + 5 end end) end)
any help would be apriciated thanks
There are many things wrong here but let me break it down:
- This script is not filtering enabled compatible which can lead to hackers hacking their stats.
- you nested the events
- you probably forgot .Value on the leaderstat
- You spelled strength wrong.
Here's a quick fix but you're gonna have to make it FE compatible or else people won't even play a game that can be hacked.
------------------< variables >---------------- local uis = game:GetService("UserInputService") local saber = script.Parent local p = game.Players.LocalPlayer local l = p.leaderstats local equipped = false ------------------< code >--------------------- saber.Equipped:Connect(function() equipped = true end) sabe.Unequipped:Connect(function() equipped = false end) uis.InputBegan:Connect(function(input) if equipped and input.UserInputType == Enum.UserInputType.MouseButton1 then l.Strenght.Value = l.Strenght.Value + 5 -- if strength is spelled incorrectly then fix it if that is the case end end)
PS: If you have FE on right now, this script will not replicate the additional strength on the server.