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

Why does this lap script not work when i duplicate it?

Asked by 5 years ago
Edited 5 years ago

i have 2 gates one goal (GoalA, GoalB) and a half (HalfA, HalfB) per set but when i put it in the next track only one of them works this is the code for it please can someone help me

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)
0
can u wrap the script using the code thingy so we can see the script properly NickAtNick 163 — 5y
0
A = script.Parent.GoalC B = script.Parent.GoalD 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.S TimLikeAnzack 0 — 5y

Answer this question