Stoil nill though char char char char
perhaps try
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
end)
end)
If its on the client then player added likely will not fire because by the time client code is run. The player has already been added.
Even if that prints nil… Is the character added event firing? The printing of the character was just to determine if the character existed before you set the listener
School? Where are you living lol (no no dont answer that)
what about
local character = Player.Character or Player.CharacterAdded:Wait()
i put in character scripts no idea why it was in player scripts and now it print the character but it gives this error every time
This while loop will stop the moment CharacterAlive is not true. It is likely running before you ever set it to true and so probably doesn’t run at all or only once.
-- services
local Players = game:GetService("Players")
-- variables
local CharacterAlive = nil
local Player = Players.LocalPlayer
local Head, Neck
print("plyh2")
-- functions
-- events
print(Player.Character)
Player.CharacterAdded:Connect(function(character)
CharacterAlive = true
Head = character:WaitForChild("Head")
Neck = Head.Neck
task.spawn(function()
while CharacterAlive do
print("Pluh")
task.wait(0.1)
end
end)
end)
Player.CharacterRemoving:Connect(function()
CharacterAlive = false
end)
- That error isn’t from your script, is it? I don’t think it’s a big deal.
- @Emskipo is right. Maybe change your loop layout to this:
task.spawn(function()
while task.wait(0.1) do
if CharacterAlive then
-- do stuff
end
end
end))
Try this variation of the code.
-- services
local Players = game:GetService("Players")
-- variables
local CharacterAlive = nil
local Player = Players.LocalPlayer
local Head, Neck
print("plyh2")
-- functions
local function DoLoop()
CharacterAlive = true
Head = Player.Character:WaitForChild("Head")
Neck = Head.Neck
task.spawn(function()
while CharacterAlive do
print("Pluh")
task.wait(0.1)
end
end)
end
-- events
if(Player.Character)then
DoLoop()
else
Player.CharacterAdded:Connect(function(character)
DoLoop()
end)
end
Player.CharacterRemoving:Connect(function()
CharacterAlive = false
end)
This could be refined more… but it should def work.
Yes it work thank you I stopped respond cus change periods
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.