Why does this code block get completely skipped over after running once?
Asked by
5 years ago Edited 5 years ago
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:
03 | if #shared.hometeam:GetPlayers() > 0 then |
04 | hFO = wFO.Parent [ "FO Home" ] .Touched:Connect( function (hit) |
05 | if hFOt then hFO:Disconnect() return end |
06 | if hit:FindFirstAncestor( "Stick" ) then |
07 | if game.Players:GetPlayerFromCharacter(hit:FindFirstAncestor( "Stick" ).Parent).Team = = shared.hometeam then |
08 | hit:FindFirstAncestor( "Stick" ).Parent:SetPrimaryPartCFrame(wFO.Parent [ "FO Home" ] .CFrame - Vector 3. new( 0 ,wFO.Parent [ "FO Home" ] .Position.Y, 0 ) + Vector 3. new( 0 ,hit:FindFirstAncestor( "Stick" ).Parent.HumanoidRootPart.Position.Y+ 1.5 , 0 )) |
09 | hit:FindFirstAncestor( "Stick" ).Parent.HumanoidRootPart.Anchored = true |
10 | hit:FindFirstAncestor( "Stick" ).Parent.Humanoid.WalkSpeed = 0 |
13 | repeat wait() until not workspace.Puck.Anchored |
14 | hit:FindFirstAncestor( "Stick" ).Parent.HumanoidRootPart.Anchored = false |
15 | hit:FindFirstAncestor( "Stick" ).Parent.Humanoid.WalkSpeed = 20 |
20 | repeat wait() until hFOt |