So I am working on a hockey game. When a player touches the square that puts then in a faceoff position, it is supposed to freeze them in place. However after the first faceoff, it seems that part of the code is simply skipped over (and I have placed a print statement that does print but does not seem to execute the code before it).
Script:
function FunctionFO()
count.Text = 31
if #shared.hometeam:GetPlayers() > 0 then
hFO = wFO.Parent["FO Home"].Touched:Connect(function(hit)
if hFOt then hFO:Disconnect() return end
if hit:FindFirstAncestor("Stick") then
if game.Players:GetPlayerFromCharacter(hit:FindFirstAncestor("Stick").Parent).Team == shared.hometeam then
hit:FindFirstAncestor("Stick").Parent:SetPrimaryPartCFrame(wFO.Parent["FO Home"].CFrame - Vector3.new(0,wFO.Parent["FO Home"].Position.Y,0) + Vector3.new(0,hit:FindFirstAncestor("Stick").Parent.HumanoidRootPart.Position.Y+1.5,0))
hit:FindFirstAncestor("Stick").Parent.HumanoidRootPart.Anchored = true
hit:FindFirstAncestor("Stick").Parent.Humanoid.WalkSpeed = 0
print("True") -- Prints true but doesn't anchor the HumanoidRootPart
hFOt = true
repeat wait() until not workspace.Puck.Anchored
hit:FindFirstAncestor("Stick").Parent.HumanoidRootPart.Anchored = false
hit:FindFirstAncestor("Stick").Parent.Humanoid.WalkSpeed = 20
end
end
end)
spawn(function()
repeat wait() until hFOt
hFO:Disconnect()
end)
end
