so im making a script to fire some events based on values when a player moves but all of the sudden script stops working and doesnt fire event i tried debugging and not a single thing works.
local script:
local Player = game.Players.LocalPlayer
local Character = Player:WaitForChild("Character")
local Humanoid = Character.Humanoid
local speed = Player.stats.Speed
local equipped = Character:WaitForChild("EquippedWeight")
local VectorZero = Vector3.new(0, 0, 0)
local db = false
local function Moved()
if Humanoid.MoveDirection ~= VectorZero then
if not db then
db = true
if equipped == "none" then
game.ReplicatedStorage.Stats.RUN:FireServer() -- fires event to add speed
elseif equipped == "100lbs" then
if speed.Value >= 100 and speed.Value < 5000 then
game.ReplicatedStorage.Stats.RUN:FireServer()
else
game.ReplicatedStorage.Errors.NotWeight:FireServer() -- fires event that opens gui saying not enough stats
end
elseif equipped == "1ton" then
if speed.Value >= 5000 and speed.Value < 500000 then
game.ReplicatedStorage.Stats.RUN:FireServer()
else
game.ReplicatedStorage.Errors.NotWeight:FireServer()
end
elseif equipped == "10ton" then
if speed.Value >= 500000 and speed.Value < 5000000 then
game.ReplicatedStorage.Stats.RUN:FireServer()
else
game.ReplicatedStorage.Errors.NotWeight:FireServer()
end
end
wait(3)
db = false
end
else
end
end
Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(Moved)
everything down to the last line doesnt work for some odd reason?
i dont know what im doing wrong so pls help.
server script:
game.ReplicatedStorage.Stats.RUN.OnServerEvent:connect(function(player)
player.stats.Speed.Value = player.stats.Speed.Value + player.Character.SpeedAdd.Value
end)

4 comments
also sorry my scripts a little messy
make sure waitforchilds arent yielding anything and make sure that your script isnt disabled
omg thank you!! i diddnt realise that getting a yield on Character would stop my script from running but after i got rid of :WaitForChild("Character") everything started to work!
"Character" isn't a child of the player