Rot is a vector 3, but needs to be cframe to rotate

local SBUI = game.ReplicatedStorage:WaitForChild("ShowBuildUI")
local player = script:FindFirstAncestorWhichIsA"Player"
local The = game.ReplicatedStorage:WaitForChild("ObjSender")

local ObjToSpawn = nil

script.Parent.place.OnServerEvent:Connect(function(player, Positiona, Rot)
	if ObjToSpawn  ~= nil then
		local Object = ObjToSpawn:Clone()
		Object.Parent = workspace
		Object:SetPrimaryPartCFrame(Positiona)
		Object:PivotTo()
	end
end)

script.Parent.Equipped:Connect(function()
	SBUI:FireClient(player)
end)

script.Parent.Unequipped:Connect(function()
	SBUI:FireClient(player)
end)

The.OnServerEvent:Connect(function(plr, object)
	if plr == player then
		ObjToSpawn = object
	end

Rot here is a vector 3 from an event. Rot cannot be turned into a cframe from the firing script, so how do i turn it into a cframe so i can use :PivotTo() for my model?

You can try CFrame.new(), and insert your Vector3 into the parenthesis. That should convert it from a Vector3 to a CFrame.

i tried that, no errors but it doent work

What do the other script(s) look like? I’m trying to find a fix but I can’t without seeing the other script(s). Also for a start, At the end of that script you have a incomplete function. Add another line after line 27 and put another end).

you can do something like

local rotation = Vector3.new(69,69,69)
local x,y,z = rotation.X, rotation.Y, rotation.Z

CFrame.new(objectposition) * CFrame.Angles(math.rad(x),math.rad(y),math.rad(z)) -- the cframe you wanted

make sure the rotation is in degrees though!

sorry i went to sleep after the last post this is the other script

local Mouse = game.Players.LocalPlayer:GetMouse()
local Positiona = nil
local Rot = Vector3.new(0, -90, 0)
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(Key)
	if Key.KeyCode == Enum.KeyCode.R then
		Rot += Vector3.new(0, -90, 0)
		
		if script.Parent:FindFirstChild("Ghost") then
			script.Parent.Ghost:Destroy()
		end
		local Ghost = Instance.new("Part", script.Parent)
		Ghost.Name = "Ghost"
		Ghost.CFrame = Positiona
		Ghost.Anchored = true
		Ghost.Size = Vector3.new(3.9, 0.35, 4)
		Ghost.Transparency = 0.8
		Ghost.Color = Color3.new(0, 0, 0)
		Ghost.Rotation = Rot

		local GhostImage = Instance.new("Decal", Ghost)
		GhostImage.Texture = "rbxassetid://13199053500"
		GhostImage.Face = "Top"
	end
end)

script.Parent.Activated:Connect(function()
	
	script.Parent.place:FireServer(Positiona, Rot)
	
end)

Mouse.Move:Connect(function()
	local GridSize = 4
	local X = math.floor((Mouse.Hit.X + GridSize / 2) / GridSize) * GridSize
	local Y = math.ceil((Mouse.Hit.Y + GridSize / 4 ) / GridSize) * GridSize - 3.85
	local Z = math.floor((Mouse.Hit.Z + GridSize / 2) / GridSize) * GridSize
	Positiona = CFrame.new(X, Y, Z)
	
	if script.Parent:FindFirstChild("Ghost") then
		script.Parent.Ghost:Destroy()
	end
	local Ghost = Instance.new("Part", script.Parent)
	Ghost.Name = "Ghost"
	Ghost.CFrame = Positiona
	Ghost.Anchored = true
	Ghost.Size = Vector3.new(3.9, 0.35, 4)
	Ghost.Transparency = 0.8
	Ghost.Color = Color3.new(0, 0, 0)
	Ghost.Rotation = Rot
	
	local GhostImage = Instance.new("Decal", Ghost)
	GhostImage.Texture = "rbxassetid://13199053500"
	GhostImage.Face = "Top"
end)

Do you think i could maybe send the rotation of the “ghost” as a cframe? and keep rot for rotating the ghost itself?

Also the reason it says “postitiona” is because i just took it off the toolbox, and VERY heavily modified it to fit my needs, like adding a object select system and more

I think you can do something like

Positiona * CFrame.Angles(math.rad(Rot.X),math.rad(Rot.Y),math.rad(Rot.Z)

how would i implement this?
char limit

Since Positiona is already a CFrame, you can do like what i said

Positiona * CFrame.Angles(math.rad(Rot.X),math.rad(Rot.Y),math.rad(Rot.Z)

or

local Rot = Vector3.new(0,90,0)
local CFrameResult = Positiona * CFrame.Angles(math.rad(Rot.X),math.rad(Rot.Y),math.rad(Rot.Z) -- which should be what you wanted

its giving me errors on the line under it

forgot to add another “)” at the end, my bad

Positiona * CFrame.Angles(math.rad(Rot.X),math.rad(Rot.Y),math.rad(Rot.Z))
1 Like

oh ok ill add that, ill tell u if it works

it kinda works, but the objects are now offset by 90 degrees

you sure the Vector3 rotations are correct?

they should be? idk, can we add to the CframeRot/CFrameResult to make it work? how do i do that

wait i found out dw
char limit

It’s an orientation.

I have two things you could do:

local cframe = CFrame.fromOrientation(vector3.X, vector3.Y, vector3.Z)

Or:

local cframe = CFrame.new(Vector3.zero, vector3).Rotation

Try both of them.