#Script not working

23 messages · Page 1 of 1 (latest)

idle summit
#

Send the script, and say the purpose of the script.

spiral moth
#
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService('ReplicatedStorage')

local Players = game:GetService("Players") 
local Player = Players.LocalPlayer
local Character = script.Parent
local char = Player.Character or Player.CharacterAdded:wait()
print('finding humanoid')
repeat wait() until char:FindFirstChild("Humanoid")
print('found')

local humanoid = char.Humanoid

local Mouse = Player:GetMouse()

local Loaded = false
local debounce = false

local Tool = script.Parent
local Event = ReplicatedStorage:FindFirstChild('ShootEvent')
local Holdable,Holding = false,false 

function Send() 
    Event:FireServer({Position = Mouse.Hit.Position})
end

Tool.Activated:Connect(function()
    if debounce == true then
        if Loaded == false then
            local OGspeed = humanoid.WalkSpeed
            humanoid.WalkSpeed = 3
            wait(3)
            humanoid.WalkSpeed = OGspeed
        else
            debounce = true
            Holding = true
            if Holdable then
                local Run
                Run = RunService.Heartbeat:Connect(function()
                    if not Holding then
                        Run:Disconnect()
                    end

                    Send()
                end)
            else
                Send()
            end
            wait(1.5)
            debounce = false
            Loaded = false
        end
    else
        return
    end
end)

Tool.Deactivated:Connect(function()
    Holding = false
end)

Tool.Unequipped:Connect(function()
    Holding = false
end)```
it's a local script, and this script is supposed to get player's mouse / checking debounce before the weapon shoots
ashen drumBOT
#

studio** You are now Level 7! **studio

idle summit
#

where u put this script at?

#

inside of an tool?

harsh falcon
#

?

spiral moth
#

yes inside a tool

idle summit
#

let me see what i can do

harsh falcon
#

i think this can help

idle summit
#

he already have this function in his script

#

ose try using pcall function

spiral moth
#

wait let me try my own way first i might know where im wrong at

idle summit
#

welp the problem is

#

on the Activated Line

#

local function Send()

spiral moth
#

oh yeah i fixed it

#

lol

idle summit
#

what was the issue?

spiral moth
#

it was more of a sequence problem

idle summit
#

Good luck 😄

spiral moth
#

thank u u too

idle summit