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

Script Error attempt to index nil with 'Character',can you fix this?

Asked by
Gigaset39 111
2 years ago

Hello world, im using ChatGPT to modify the folowing script, but it, its a little bit.. yeah..

in the rror says: attempt to index nil with 'Character' -line 5

01local Players = game:GetService("Players")
02local TweenService = game:GetService("TweenService")
03 
04local player = Players.LocalPlayer
05local character = player.Character or player.CharacterAdded:Wait()
06local humanoid = character:WaitForChild("Humanoid")
07local rootPart = character:WaitForChild("HumanoidRootPart")
08local camera = workspace.CurrentCamera
09 
10-- Wait for character to be initialized
11while not character do
12    character = player.Character or player.CharacterAdded:Wait()
13    wait()
14end
15 
View all 39 lines...
0
BTW, ChatGPT is amazing! Gigaset39 111 — 2y

1 answer

Log in to vote
1
Answered by
manith513 121
2 years ago

This should be in a local script. I'm assuming that because you used chatGPT that you forgot to do this. Put it into a local script and the error should subside.

Ad

Answer this question