So I have this code system and when I use this one function it just loops itself for some random reason
Module Script:
function _____FD______.giveCar(_________________FP_______________,textbox,_____________DISPLAYCAR_________,frame,rotateCar)
frame:TweenPosition(UDim2.new(0.25,0,1,0),"In","Linear",1)
script.Parent.Parent.Parent.CarAward.ViewportFrame:TweenPosition(UDim2.new(0.353, 0,0.315, 0),"Out","Linear",1)
local cloneCarWorkspace = _____________DISPLAYCAR_________:Clone()
local cloneCarViewport = _____________DISPLAYCAR_________:Clone()
cloneCarWorkspace.Parent = workspace["awardedCars_".._________________FP_______________.Name]
cloneCarWorkspace:FindFirstChild("A-Chassis Tune"):Destroy()
cloneCarViewport:FindFirstChild("A-Chassis Tune"):Destroy()
cloneCarWorkspace:FindFirstChild("DriveSeat"):Destroy()
cloneCarViewport:FindFirstChild("DriveSeat"):Destroy()
cloneCarWorkspace:FindFirstChild("Humanoid"):Destroy()
cloneCarViewport:FindFirstChild("Humanoid"):Destroy()
cloneCarViewport.Parent = script.Parent.Parent.Parent.CarAward.ViewportFrame
local count = 0
repeat
cloneCarViewport:SetPrimaryPartCFrame(cloneCarViewport.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0,0.1,0))
wait(0.05)
count = count + 0.05
until count >= 3
textbox:ReleaseFocus()
script.Parent.Parent.Parent.CarAward.ViewportFrame:TweenPosition(UDim2.new(0.353, 0,-0.4, 0),"In","Linear",1)
frame:TweenPosition(UDim2.new(1,0,1,0),"Out","Linear",1)
wait(1)
cloneCarViewport:Destroy()
cloneCarWorkspace:Destroy()
game.ReplicatedStorage.Events.changeValue:FireServer(_________________FP_______________:WaitForChild("OwnedVehicles")[_____________DISPLAYCAR_________.Name],1)
end
Local Script:
if v.Money ~= 0 then
rewards.moneyReward(player,"Money",v.Money)
code.TextEditable = false
code.Text = "Redeemed for "..v.Money.." money!"
wait(1)
code.TextEditable = true
code.Text = "..."
break
elseif v.Car ~= "None" then
rewards.giveCar(player,textbox,v.Car,frame,rotateCar)
--rewards:destroyCar(player,workspace["awardedCars_"..player.Name],script.Parent.Parent.CarAward.ViewportFrame,frame)
end
So what happens is when it goes to
script.Parent.Parent.Parent.CarAward.ViewportFrame:TweenPosition(UDim2.new(0.353, 0,-0.4, 0),"In","Linear",1)
it will just start the function again. Why could this be happening?