Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why doesnt my user input service work?

Asked by
seikkatsu 110
4 years ago

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

1 answer

Log in to vote
1
Answered by 4 years ago

There are many things wrong here but let me break it down:

  1. This script is not filtering enabled compatible which can lead to hackers hacking their stats.
  2. you nested the events
  3. you probably forgot .Value on the leaderstat
  4. 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.

0
ok so i don't understand line 17. when you say equipped you mean that the equipped variable is true am i right? seikkatsu 110 — 4y
0
nevermind i got it, thank you seikkatsu 110 — 4y
Ad

Answer this question