I made a script that spawns a part on the Player head
It works fine but if the player dies then I get this warning:
Infinite yield possible on 'Workspace.itz_rennox:WaitForChild("Head")'
Stack Begin
15:12:05.167 - Script 'ServerScriptService.Bolt.Script', Line 9
15:12:05.168 - Stack End
Then the script dont work anymore
This is the Script :
game.ReplicatedStorage.Bolt.Bolt.OnServerEvent:Connect(function(plr)
if plr.CD.Value == true then
else
wait(0.1)
plr.CD.Value = true
local char = plr.Character or plr.CharacterAdded:Wait()
local CloneBolt = game.ReplicatedFirst.GameObj.Bolt:Clone()
CloneBolt.Parent = game.Workspace.Storage.Bolt
CloneBolt.CFrame = CFrame.new(char:WaitForChild("Head").Position)
CloneBolt.CFrame = CloneBolt.CFrame * CFrame.fromEulerAnglesXYZ(0,-0.5,-1.5)
CloneBolt.Sound:Play()
wait(1)
plr.CD.Value = false
CloneBolt:Destroy()
end
end)
I do not think that this warning is related to the code you have posted as “Workspace.itz_rennox” is not used in this code. Double check where this is from.
In most cases you can click on the output line to bring up the script where the output is from.
Do you have any other scripts that might be affecting the Head? The code you provided seems fairly working to me and shouldn’t be making the error you’re giving.