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

Why aren't local scripts running inside my tool?

Asked by
Viking359 161
6 years ago

I have a tool in the starter pack that has a local script inside of it. The script itself should work fine, but it doesn't even run when I have FE on. I've tried putting in a local script that just has print("Should be running") but it doesn't print. Local script are supposed to work if they are a descendant of the backpack, which the tool is, but it isn't running. Server scripts work fine. This is the script(the damage part will be moved to a remote event later).

function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
local rs = game:GetService("ReplicatedStorage")
local player = script.Parent.Parent.Parent
local name = player.Name
local o = name.."swordout"
local u = name.."swordup"
local s = name.."slashsound"
local f = rs.PlayerStuff
local so = f:FindFirstChild(o)
local su = f:FindFirstChild(u)
local sou = f:FindFirstChild(s)
so:FireServer()
sou:FireServer()

    wait(.2)
su:FireServer()
    end
end
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.Q)

debounce = false
target = "Humanoid"
script.Parent.Handle.Touched:Connect(function (hit)
if debounce == false and hit.Parent:FindFirstChild(target) then
local Players = game:GetService("Players")
local damage = script.Parent.Damage.Value
local nam = hit.Parent.Name
if Players:FindFirstChild(nam) then
local hitplayer = Players:FindFirstChild(nam)
local hpc = hitplayer.Character
    local hum = hpc.Humanoid
hum.Health = hum.Health -damage
local debounce = true
wait(1)
local debounce = false
    end
end
end)

The local script is directly inside the tool which is directly inside the StarterPack. Why won't it run?

Answer this question