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?
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).
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
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
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