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

UserinputService does not work properly, any solutions ?

Asked by 4 years ago

So, basically this script was supposed to work i assume, the script should've run something every time i hold my mouse's left button and then stop when i release it, but instead when i click once it just runs without stopping, but if you hold it a little longer, it works fine, i don't understand why isn't it working, i hope you can help me.

tool.Equipped:Connect(function()
    game.ReplicatedStorage.Equip:FireServer()
    mouse.Icon = "http://www.roblox.com/asset/?id=79658449"
    TextLabel.Visible = true

    UIS.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then 
            pressed = true  
            while pressed and tool.Equipped do          
                if Ammo1 <= 0 then
                    pressed = false
                else
                    Ammo1 = Ammo1 - 1
                    tool.GunShot:Play()
                    if mouse.Target.Parent:FindFirstChild("Humanoid") then
                        script.Parent.Damage:FireServer(mouse.Target)
                        tool.Enabled = false
                        print("target hit")
                        wait(0.09)
                        tool.Enabled = true     
                    else 
                        tool.Enabled = false
                        print("miss")
                        wait(0.09)
                        tool.Enabled = true

    UIS.InputEnded:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then  
            pressed = false
0
I think in the line 30 the "if" needs a "end" PepeElToro41 132 — 4y
0
Wait a minute, all the "if" need a a end .-. PepeElToro41 132 — 4y
0
i just didnt include the ends Random_Haxer5 10 — 4y

Answer this question