(repost from dead topic) Model not pivoting to :GetPivot()

This script is server sided and runs fully without errors or anything in console. When using PivotTo() in other scripts (with comparably similar code) it works fine. The character teleports to the car but the car doesn’t teleport to mp . Here is the code with some parts omitted. Just remember that no warnings or errors get outputted to console, and everything is triggered via proximityprompt. mp is a part.

local p = script.Parent.Torso.Prompt
local r = script.Parent.Head.Prompt
local cs = game.Workspace.Map.Buildings.CarShop.Placepart
local ss = game:GetService("ServerStorage"):WaitForChild("Cars")
local chs = game:GetService("Chat")
local guy = script.Parent

local function oporem()
	local ya = cs:FindFirstChild("Open")
	if ya then
		return "Open"
	else
		return "Occupied"
	end
end

-- proximityprompt trigger

if mp then
			plr:WaitForChild("leaderstats").Cash.Value = plr:WaitForChild("leaderstats").Cash.Value - p.Cost.Value
			guy.Torso.Audio:Play()
			mp.Name = "Occupied"
			local nc = workspace.Map.Misc.cars:FindFirstChild(plr.DisplayName.."'s car")
			nc:PivotTo(mp:GetPivot())
			local char = plr.Character or plr.CharacterAdded:Wait()
			char:PivotTo(nc.DriveSeat.CFrame + Vector3.new(0, 1, 0))
			wait(5)
			mp.Name = "Open"
		else

Any help would be appreciated

What exactly are you wanting this to do, and what is it doing instead?

When you activate the proximity prompt, it’s supposed to teleport the car to mp and then teleport you to it. Instead, it just teleports the character to the car…

ok, so it is supposed to do 2 teleports… 1 is teleport car to location mp, then teleport you, to the car, correct?

Yeah that is what it is supposed to do

ok, I will look at it and see what I can do, can you show what ‘mp’ is, and what is the structure of the car, its hierarchy?

also, is this on server or client?


all of these parts are potential mp's

Car is a model… I don’t know what you mean by hierarchy.

This is on server

it looks like you didn’t post the complete script, it ends with an ‘else’
is there more to it?

Yes but it all runs fine, if you want to see the whole thing then here it is

r.Triggered:Connect(function(plr)
	if plr:WaitForChild("leaderstats").Cash.Value >= r.Cost.Value and workspace.Map.Misc.cars:FindFirstChild(plr.DisplayName.."'s car") then
		local e = oporem()
		local mp = cs:FindFirstChild(e)
		if mp then
			plr:WaitForChild("leaderstats").Cash.Value = plr:WaitForChild("leaderstats").Cash.Value - p.Cost.Value
			guy.Torso.Audio:Play()
			mp.Name = "Occupied"
			local nc = workspace.Map.Misc.cars:FindFirstChild(plr.DisplayName.."'s car")
			nc:PivotTo(mp:GetPivot())
			local char = plr.Character or plr.CharacterAdded:Wait()
			char:PivotTo(nc.DriveSeat.CFrame + Vector3.new(0, 1, 0))
			wait(5)
			mp.Name = "Open"
		else
			chs:Chat(p.Parent, "It seems no parking space is available for your car.", Enum.ChatColor.Red)
		end
	elseif not workspace.Map.Misc.cars:FindFirstChild(plr.DisplayName.."'s car") then
		chs:Chat(p.Parent, "You do not have a car for me to locate.", Enum.ChatColor.Red)
	elseif plr:WaitForChild("leaderstats").Cash.Value < r.Cost.Value then
		chs:Chat(p.Parent, "You cannot afford this.", Enum.ChatColor.Green)
	end
end)

also please read my whole post, almost everything you’ve asked about was detailed in the original

I am not trying to be rude in saying this, but I did read the original, and considering I am the only one responding to your problem, it was most likely not very clear to anyone else.

As long as someone is trying to help you, don’t stress over having to repeat information if they ask, the end result is you might get this solved, so I would think that is worth it.

2 Likes

I tried so hard to wrap my head around this code, and even tried to re-create it in studio, but, this just makes no sense to me.
Sorry.

1 Like

Yea idk what happening with it either, thank you for trying harder than most people do

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.