Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I position a seat relative to another seat?

Help, I'm trying to make a slot car connector, the problem I am having is trying to position the seat,,,, when it spawns the seat is still the same position as the old seat. Help???

local tool = script.Parent
local event = tool:WaitForChild("Signal2")
local function ReceiveSignal2(point)
	local remotescreen = tool.Handle
	local vehtxt = remotescreen.Text
	if point.Parent.Name ~= "Piece1" then
		vehtxt.Value = "Could not identify track. Either it is not the starting piece, or it is not a track."
		wait(5)
		vehtxt.Value = "Click on the starting piece of slot track."
	else
		local track = point.Parent
		local car = tool.Slot
		local trackname = point.Parent.Parent
		vehtxt.Value = "Successfully got " .. trackname.Name
		tool.Track.Value = track
		if point.Name == "LLane" then
			car.Value.PrimaryPart.Lane.Value = "L"
		elseif point.Name == "RLane" then
			car.Value.PrimaryPart.Lane.Value = "R"
		end
		car.Value.PrimaryPart.Track.Value = trackname
		car.Value.PrimaryPart.CurrentRoad.Value = track
		car.Value:MoveTo(point.MovePoint.Position)
		wait(2)
		car.Value.PrimaryPart.Anchored = true
		local number = 0
		for i, v in pairs(trackname.Controllers:GetChildren()) do
			if v:IsA("VehicleSeat") then
				number = number + 1
			end
		end
		car.Value.Parent = trackname.Cars
		local seatnumber = number
		local newcontroller = trackname.Controllers.Control1:Clone()
		newcontroller.Name = "Control" .. seatnumber + 1
		local oldcontrollernumber = seatnumber - 1
		if oldcontrollernumber == 0 then
			oldcontrollernumber = 1
		end
--What I am having problems with
		local offsetToChar = newcontroller.CFrame:PointToObjectSpace(trackname.Controllers["Control" .. oldcontrollernumber].Position)
		newcontroller.Position = newcontroller.CFrame:PointToWorldSpace(offsetToChar + Vector3.new(-3, 0, 0))
		newcontroller.Car.Value = car.Value
		newcontroller.Parent = trackname.Controllers
		wait(1)
		vehtxt.Value = ""
	end
end
event.OnServerEvent:Connect(function(player, mouseEvent)
	print(player, mouseEvent)
	local mouse = mouseEvent
	ReceiveSignal2(mouse)
end)

1 comment

0

If i understood your question correctly, i think i know what to do

1 answer

You can use this:

local car = game.Workspace.car
local cooldown = 3 -- put the cooldown in seconds here
local onCooldown = false
local backup = car:Clone()
function clone(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if not onCooldown then
			onCooldown = true
			local yes = backup:Clone()
			yes.Parent = game.Workspace
			yes:MoveTo(Vector3.new(312.477, 9.1, -274.952))

			wait(cooldown)
			onCooldown = false

		end
	end

end

script.Parent.Touched:Connect(clone)

Edit it to fix your needs

3 comments

0

That doesn't work at all, the seat moves in the wrong direction, because the X and Z axis are flipped.

0

that doesn't work! It worked for me... idk

0

I don't know, I'll start to check

This discussion is preserved as it was. New answers, comments, and votes are closed.