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

Why does this code block get completely skipped over after running once?

Asked by
poke7667 142
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:

01function FunctionFO()
02    count.Text = 31
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 - Vector3.new(0,wFO.Parent["FO Home"].Position.Y,0) + Vector3.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
11                    print("True") -- Prints true but doesn't anchor the HumanoidRootPart
12                    hFOt = true
13                    repeat wait() until not workspace.Puck.Anchored
14                    hit:FindFirstAncestor("Stick").Parent.HumanoidRootPart.Anchored = false
15                    hit:FindFirstAncestor("Stick").Parent.Humanoid.WalkSpeed = 20
View all 23 lines...

Answer this question