So, in my Local Script, stored inside of a tool, doesn't run after all the variables are defined. Any solutions?

--Get player
local Player = game.Players.LocalPlayer

--Load
repeat wait() until Player.Character

repeat wait() until Player.Character.Humanoid
print("loaded")

--Get humanoid
local Humanoid = Player.Character.Humanoid

--Get Bools
local CanAttack = game.ReplicatedStorage.NewValues:WaitForChild(Player.Name):WaitForChild("CanAttack")
local AttackPlaying = game.ReplicatedStorage.NewValues:WaitForChild(Player.Name):WaitForChild("AttackPlaying")

--Get UserInputService
local UserInputService = game:GetService("UserInputService")

--Get animation track
local IdleTrack = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.IdleSplitter)
local WalkTrack = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.WalkSplitter)
local RunTrack = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.AllClassRun)

local LightAttackTrack = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.LightAttackSplitter)
local HeavyAttackTrack = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.HeavyAttackSplitter)

--Get hitbox
local Hitbox = script.Parent.Parent.Hitbox

--Get AttackFired
local AttackFired = game.ReplicatedStorage.BindableFunctions.Attack.AttackFired

local Hitbox = script.Parent.Parent.Hitbox

local HitDebounce = false
print("idle played")

11 comments

0

I forgot to say something, the print at the bottom doesnt print.

0

any errors?

0

Nope. No errors.

0

Make sure it's placed at a proper area where LocalScripts can run. StarterGui, StarterCharacter, ReplicatedFirst

0

It's inside of a Tool in StarterPack. It was working completely fine before, but it isn't working now.

0

Try to put it in StarterPlayerScript folder

1

repeat wait() should be replaced by either :WaitForChild() or event:Wait(), for example character should be "char = player.Character or player.CharacterAdded:Wait()" and humanoid should be "char:WaitForChild("Humanoid")"

0

also if it says anything like "Infinite yield on thing:WaitForChild()" that counts as an error and means the child cant be found

0

the repeat wait() works fine I put a print to test and it worked.

0

it works fine but it shouldnt be used anyways. it can wait longer than you might want it to which will ultimately cause problems

0

Didn't work :(