Why does my WaitForChild not working? I’m trying to acess the player’s character, but it says:
Workspace.Rapideed.FireBallscript.Fireball:8: attempt to index nil with 'WaitForChild'
(TheScript is also in PlayerCharacterScripts
Script:
local Player = game.Players.LocalPlayer
local Character = Player.Character
Thank you for reading.
alessdai
(alessdai)
June 3, 2021, 9:46pm
#2
attempt to index nil with ‘WaitForChild’ means you all trying to wait for a child with a parent that doesnt exist
LMVM2041
(League)
June 3, 2021, 9:47pm
#3
If you are accessing the character within a local script, just do:
local character = game.Players.LocalPlayer.Character
You can’t use “WaitForChild” inside a local script. It generally works in scripts.
uugnut6
(uugnut6)
June 3, 2021, 9:48pm
#5
are you sure you spelled everything corectly
LMVM2041
(League)
June 3, 2021, 9:49pm
#6
For other properties, you can. Lemme rephrase:
There are simpler ways to access the players character than using WaitForChild.
1 Like
It says:
Workspace.Rapideed.FireBallscript.Fireball:8: attempt to index nil with ‘Character’
alessdai
(alessdai)
June 3, 2021, 9:49pm
#8
LocalPlayer does not work inside of a Server Script btw
1 Like
LMVM2041
(League)
June 3, 2021, 9:50pm
#9
What is your local script going to do? What’s its purpose?
uugnut6
(uugnut6)
June 3, 2021, 9:50pm
#10
use game.Players.PlayerAdded and player.CharacterAdded
I gave you the script on the top.
alessdai
(alessdai)
June 3, 2021, 9:50pm
#12
I can assure you this will not help unless context is provided
LMVM2041
(League)
June 3, 2021, 9:50pm
#13
You are using a local script right?
Correct and it’s in StarterCharacterScripts
uugnut6
(uugnut6)
June 3, 2021, 9:51pm
#15
player.Character or player.CharacterAdded:Wait()
LMVM2041
(League)
June 3, 2021, 9:52pm
#16
Whats the context of the script? What is it supposed to do? This can help us understand if you placed your script in the wrong category or help you make the script.
This is supposed to do damage to the player.
uugnut6
(uugnut6)
June 3, 2021, 9:53pm
#18
where are you using waitforchild?
LMVM2041
(League)
June 3, 2021, 9:54pm
#19
If they touch an object or just damage the player without them doing anything?
It’s a projectile. That does damage when touched.