Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Wait is not a valid member?[Solved]

So I am basically trying to access a local player character but it gives me this weird error when I am waiting for it to load.

Inside a tool, localscript

local player = game:GetService("Players").LocalPlayer
repeat wait() until player.Character
local chr = player.Character
local tool = script.Parent
local handle = tool:FindFirstChild("handle") --Variables
local mouse = player:GetMouse()

Fixed

local player = game:GetService("Players").LocalPlayer
local chr = player.Character or player.CharacterAdded:wait()
local tool = script.Parent
local handle = tool:FindFirstChild("handle") --Variables
local mouse = player:GetMouse()

Output

22:01:21.180 - Wait is not a valid member 22:01:21.181 - Script 'Players.Player1.Backpack.Tool.LocalScript', Line 2 22:01:21.181 - Stack End

Error appears before I equip the tool!

6 comments

0

This is rather odd.

0

This doesn't seem right... is there anything else wrong?

0

Nope just that because of this error I can't test anything I do with the tool, it errors directly and the tool is out of function, kinda

0

Doesn't "wait()" need to be uppercase? ("Wait()")

0

Nope, when it's uppercase then it gives this error but my wait is literally lowecasse: https://gyazo.com/9c0b1cbd6388d6b82341ae72f5e4f0b4

0

Maybe you should try wait(1)? This has happened to me before, and it seemed to help.

1 answer

First of all, instead of "repeat wait() player.Character" use "player**:WaitForChild("Character")**". Second, you shouldn't instatiate anymore the method "wait()" to an event, since it's deprecated. So CharacterAdded:wait() will work badly(at least for me).

This discussion is preserved as it was. New answers, comments, and votes are closed.