i have a problem that when i load into the game, anything after the “CharacterAdded” event doesnt fire, as shown in the screenshots but i tried checking if the character does exist before the characteradded event and it says it does exist, do you guys know why by any chance??? ( oh yeah by the way all of this is for walking sounds)
if not game:IsLoaded() then
game.Loaded:Wait()
end
print("game loaded")
local char = game.Players.LocalPlayer.Character
if char then
print("character exists")--this does print on the output when joining
end
game.Players.LocalPlayer.CharacterAdded:Connect(function(char)--anything after this line doesnt fire for some reason
print("char loaded")
local walkingsounds = game.SoundService.walkingsounds:GetChildren()
for i, sounds in walkingsounds do
local clonesounds = sounds:Clone()
clonesounds.Parent = char["Right Leg"]
end
while task.wait(0.1) do
print("e")
local humanoid = char:FindFirstChild("Humanoid")
local root = char:FindFirstChild("HumanoidRootPart")
local rayOrigin = char.Torso.Position
local rayDirection = Vector3.new(0,-5,0)
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
rayParams.FilterDescendantsInstances = {
workspace.Baseplate,
char:GetDescendants()
}
if humanoid.MoveDirection.Magnitude > 0 and root.Velocity.Magnitude > 0.2 then
local rayResult = workspace:Raycast(rayOrigin,rayDirection,rayParams)
if not rayResult or rayResult == nil then continue end
if rayResult then
if rayResult.Instance:HasTag("Grass") then
local grassSFX = char["Right Leg"].grass
print("grass")
task.wait(0.1)
grassSFX:Play()
elseif rayResult.Instance:HasTag("Wood") then
print("wood")
elseif rayResult.Instance:HasTag("Water") then
print("water")
elseif rayResult.Instance:HasTag("Metal") then
print("metal")
elseif rayResult.Instance:HasTag("Stone") then
local stoneSFX = char["Right Leg"].stone
task.wait(0.1)
stoneSFX:Play()
print("stone")
end
end
end
end
end)