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

Can someone help me with this Character script which isnt working?

Asked by 2 years ago

local Players = game:GetService("Players") local player = Players.LocalPlayer local character = player:FindFirstChild("Character") local KillStreak = script.Parent local Humanoid = character:FindFirstChild("Humanoid")

script.Parent = character:FindFirstChild("Torso")

Workspace.Part.BillboardGui.TextLabel.Script:3: attempt to index nil with 'Character' is what is says in the output

Anyone know why?

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

You tried referencing an object which doesn't exist.

The character's parent is in game.Workspace.

The property 'Character' of a player object is the Player's Character so we can just do player.Character

We can use a repeat wait() until for the Character to load

repeat wait() until player.Character
local Players = game:GetService("Players")
 local player = Players.LocalPlayer 
local character = player.Character
local KillStreak = script.Parent
local Humanoid = character:FindFirstChild("Humanoid")

script.Parent = character:FindFirstChild("Torso")

And btw, can you use the code block feature next time??

Ad

Answer this question