So I have a scipt that sees if there is a certain item in the player. If its not then it just moves on right?(Cause it is a IF statement)
But it is still giving me an error. Why is this happening?
if not player.Failed then -- this is where the error is.
Dede_4242
(Dede_4242)
March 31, 2023, 12:45am
#2
Could you show us an error please?
We canât help you without it
19:45:12.384 Failed is not a valid member of Player "Players.Froyo1002YT" - Server - Load/SetupPlayer:84
19:45:12.384 Stack Begin - Studio
19:45:12.384 Script 'ServerScriptService.Load/SetupPlayer', Line 84 - function saveData - Studio - Load/SetupPlayer:84
19:45:12.384 Script 'ServerScriptService.Load/SetupPlayer', Line 110 - Studio - Load/SetupPlayer:110
19:45:12.385 Stack End - Studio
19:45:17.019 Disconnect from ::ffff:127.0.0.1|58129
What is the error? If statements donât prevent errors from occurring, they simply check if a condition passes.
Dede_4242
(Dede_4242)
March 31, 2023, 12:46am
#5
Failed isnât a part of the Player, thatâs the problem
DasKairo
(Cairo)
March 31, 2023, 12:46am
#6
Use FindFirstChild
to prevent this error.
Oh. I thought that it would not create an error.
How do I fix this?
Youâre trying to access a property from the Player that doesnât exist. If you stored a BoolValue, you need to access its Value
property:
if not player.Failed.Value then
If you did not use a BoolValue, what exactly are you looking for?
Oh I think I know how to fix this.
I just need to swap out .Failed for findFirstChild(âFailedâ)
1 Like
Dede_4242
(Dede_4242)
March 31, 2023, 12:52am
#10
Yes, but it would be:
if player:FindFirstChild(âFailedâ) == nil then
return end
elseif player:FindFirstChild(âFailedâ) then
--do stuff
1 Like
Cynacol
(Cynacol)
March 31, 2023, 2:19am
#11
donât mark yourself as the solution. only the person who helped you the most in the problem
3 Likes
Oops I clicked on the wrong thing.
Thanks
system
(system)
Closed
April 15, 2023, 3:31pm
#13
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.