i have two goals start/finish and half way they detect when a player passes but when i have two of the same script in my game it does not work this is my script:
A = script.Parent.GoalA
B = script.Parent.GoalB
A.CFrame = CFrame.new(A.Position,B.Position)
B.CFrame = CFrame.new(B.Position,A.Position)
C = A:Clone()
Dist = (A.Position-B.Position).magnitude
C.Size = C.Size + Vector3.new(-5,-1,Dist-2)
C.CFrame = A.CFrame + A.CFrame.lookVector*Dist/2
C.CFrame = CFrame.new(C.Position,A.Position)
C.Mesh:Remove()
C.Parent = A.Parent
C.Name = "Goal"
D = C:Clone()
D.Size = D.Size + Vector3.new(0,-100,0)
D.CFrame = C.CFrame + Vector3.new(0,C.Size.y/2+0.5,0)
D.Parent = A.Parent
D.Name = "GoalRib"
C.Transparency = 1
C.CanCollide = false
Goal = C
------
A = script.Parent.HalfA
B = script.Parent.HalfB
A.CFrame = CFrame.new(A.Position,B.Position)
B.CFrame = CFrame.new(B.Position,A.Position)
C = A:Clone()
Dist = (A.Position-B.Position).magnitude
C.Size = C.Size + Vector3.new(-5,-1,Dist-2)
C.CFrame = A.CFrame + A.CFrame.lookVector*Dist/2
C.CFrame = CFrame.new(C.Position,A.Position)
C.Mesh:Remove()
C.Parent = A.Parent
C.Name = "Half"
D = C:Clone()
D.Size = D.Size + Vector3.new(0,-100,0)
D.CFrame = C.CFrame + Vector3.new(0,C.Size.y/2+0.5,0)
D.Parent = A.Parent
D.Name = "HalfRib"
C.Transparency = 1
C.CanCollide = false
Half = C
game.Players.PlayerAdded:connect(function(Player)
local L = Instance.new("IntValue")
L.Name = "leaderstats"
local Lap = Instance.new("IntValue")
Lap.Name = "Lap"
Lap.Parent = L
L.Parent = Player
local LastCp = Goal
Half.Touched:connect(function(hit)
if game.Players:playerFromCharacter(hit.Parent) ~= Player then return end
if LastCp == Half then return end
if LastCp == Goal then LastCp = Half end
end)
Goal.Touched:connect(function(hit)
if game.Players:playerFromCharacter(hit.Parent) ~= Player then return end
if LastCp == Goal then return end
if LastCp == Half then LastCp = Goal Lap.Value = Lap.Value+1 end
end)
end)

1 comment
Consider explaining what all your variables represent. That will save time for anyone looking to answer your question so that they can spend more time helping and less time interpreting.