Teleporting Finish Line and moving bug

  1. I want to achieve a finish line that will teleport the bike back to its place and the player back to the lobby.

  2. Everything works except that when I come back for the next round and try to ride the bike it teleports me close to the finish line and makes me go back to the lobby as if I already reached it.

  1. I have tried cleaning my script and doing a bunch but it still doesn’t work. I have been trying to fix this for 3 days straight which is very frustrating. If you could help I would be extremely thankful.

script where the touched happens

local players = game:GetService("Players")
local Rep = game:GetService("ReplicatedStorage")
local remote = game.ReplicatedStorage.remotes.intermission
local switchTeams = game.ReplicatedStorage.remotes.switchTeams
local otherRemote = game.ReplicatedStorage.remotes.OtherRemote
local teleportBackRemote = game.ReplicatedStorage.remotes.telePortbackRemote
local winRemote = game.ReplicatedStorage.remotes.win
local FirstValue = game.Workspace.finishBikeRacePart.First
local SecondValue = game.Workspace.finishBikeRacePart.Second
local ThirdValue = game.Workspace.finishBikeRacePart.Third




local part = game.Workspace.finishBikeRacePart
local touchedAllowed = true

local connection


local function touchedFunctionForPart(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		print("got player from the hit")
	elseif hit.Parent:FindFirstChild("Humanoid") and not game.Players:GetPlayerFromCharacter(hit.Parent) then
			print("got bike from skid")
			local sit = hit.Parent:FindFirstChild("sit")
			pcall(function()
				weld = sit.Weld

				char = weld.Part0.Parent
			end)
			local plr = game.Players:GetPlayerFromCharacter(weld.Part0.Parent)
			if plr.canTouchFinishLine.Value == true then
				plr.canTouchFinishLine.Value = false
				print("humanoid Detected")

				

				local hum = weld.Part0.Parent:FindFirstChild("Humanoid")



				plr.isRiding.Value = "false"

				


				pcall(function()
					print(char)
					weld:Destroy()
					print(sit.Parent)
				    sit.Parent.HumanoidRootPart.BodyVelocity.MaxForce = Vector3.new(0,0,0)
				sit.Parent.HumanoidRootPart.BodyVelocity.Velocity = Vector3.new(0,0,0)
				print(char.HumanoidRootPart.Position)
					print(game.Workspace.mainSpawnLocation.Position)
					--game.Workspace:FindFirstChild(char).HumanoidRootPart.Position = game.Workspace.mainSpawnLocation.Position
				end)
				
				
				local ActiveTracks = hum:GetPlayingAnimationTracks()
				for _,v in pairs(ActiveTracks) do
					v:Stop()
				end

				

				print("has been through the stopping of animations")

				wait(1)
				hit.Parent.Value.Value = true
				hit.Parent.HumanoidRootPart:FindFirstChild("BodyVelocity").MaxForce = Vector3.new(0,0,0)
				hit.Parent.HumanoidRootPart.Position = hit.Parent.bikeOriginalPos.Value
				char.HumanoidRootPart.Position = game.Workspace.mainSpawnLocation.Position
				
				print("setted bike and humanoid location")
				

				local placementUI = game.ReplicatedStorage.TextLabel:Clone()

				placementUI.Parent = game.Workspace.ResultPanel.SurfaceGui.backroundFrame
				
				if FirstValue.Value == "" then
					FirstValue.Value = plr.UserId
				elseif SecondValue.Value == "" and FirstValue.Value ~= "" then
					SecondValue.Value = plr.UserId
				elseif ThirdValue.Value == "" and SecondValue.Value ~= "" and FirstValue.Value ~= "" then
					ThirdValue.Value = plr.UserId
				elseif ThirdValue.Value ~= "" and SecondValue.Value ~= "" and FirstValue.Value ~= "" then
					return print("all top 3 places are taken")
				end
				
				
			wait(5)
			plr.canTouchFinishLine.Value = true	
			
			print(plr)
			

			end
	end
end

connection = part.Touched:Connect(touchedFunctionForPart)

I recommend using pre-made maps then loading them when the round starts, or as another option you could easily keep the map where it is and delete the bikes when the round ends and add them back in once the round begins, that should fix all your issues :smiley: