Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

Wait is not a valid member?[Solved]

Asked by
Kryddan 261 Moderation Voter
8 years ago

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!

0
This is rather odd. koolkid8099 705 — 8y
0
This doesn't seem right... is there anything else wrong? TheDeadlyPanther 2460 — 8y
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 Kryddan 261 — 8y
0
Doesn't "wait()" need to be uppercase? ("Wait()") GoldenPhysics 474 — 8y
View all comments (2 more)
0
Nope, when it's uppercase then it gives this error but my wait is literally lowecasse: https://gyazo.com/9c0b1cbd6388d6b82341ae72f5e4f0b4 Kryddan 261 — 8y
0
Maybe you should try wait(1)? This has happened to me before, and it seemed to help. PyccknnXakep 1225 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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).

Ad

Answer this question