The code your going to see is somewhat complicated, messy, and possibly confusing. But what I’m trying to do is basically make a build system, where at the final function of the script, has part = hitsize (hitsize is a clone of a union). The original union has an orientation of 90,0,0, but the clone has an orientation of 0,0,0, and it seems that as hard as I try, I can’t change the x axis orientation of the part. But I can change the y axis rotation easily as seen in the code when I press the r key it rotates just fine. But for some reason, I can’t force it to rotate back to 90 degrees on the x axis. I’m probably confusing you as you read this, I’m not sure if I have provided enough info, probably not, but if you have any questions just ask.
But I believe there is something in the local script that resets the x axis to 0. Soo IS THERE ANYTHING IN THE CODE THAT COULD POSSIBLY AFFECT THIS
local tool = script.Parent
local gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("BuildSystemGui")
local event3 = game.ReplicatedStorage.SizeChanger
local part = game.ReplicatedStorage.BuildStorage.DefaultView
part.Transparency = 0.5
part.Color = Color3.new(0, 1, 0)
part.Size = Vector3.new(3,3,3)
part.Anchored = true
part.Parent = nil
part.CanCollide = false
local offset = Vector3.new(0, part.Size.y/2, 0)
local isRotating = false
local function updatePosition()
if not isRotating then
local mouse = game.Players.LocalPlayer:GetMouse()
local hitPos = mouse.Hit.p
local ray = Ray.new(hitPos + offset, Vector3.new(0, -10, 0))
local partObj, pos = workspace:FindPartOnRayWithIgnoreList(ray, {part})
if partObj then
part.CFrame = CFrame.new(pos + offset, pos + offset + (part.CFrame.lookVector * Vector3.new(1, 0, 1)))
local playerPos = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
if (part.Position - playerPos).magnitude > 20 then
part.Color = Color3.new(1, 0, 0)
else
part.Color = Color3.new(0, 1, 0)
end
end
end
end
local function onEquipped()
gui.Enabled = true
part.Transparency = 0.5
isRotating = false
tool.Activated:Connect(function(clicked)
if part.Color == Color3.new(0, 1, 0) then
local mouse = game.Players.LocalPlayer:GetMouse()
local pos = part.Position
local rotation = part.Orientation
print(rotation)
game.ReplicatedStorage.Build:FireServer(pos, rotation)
else
print("not in range")
end
end)
end
local function onUnequipped()
gui.Enabled = false
part.Transparency = 1
end
tool.Equipped:Connect(onEquipped)
tool.Unequipped:Connect(onUnequipped)
while not tool:IsA("Tool") do
tool = tool.Parent
wait()
end
local bKeyPressed = false
game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.B and not gameProcessed then
bKeyPressed = not bKeyPressed
if bKeyPressed then
part.Parent = workspace.Terrain
updatePosition()
else
part.Parent = nil
end
end
end)
local prevPos = part.Position
local prevTime = tick()
local updateTime = 1/120
game:GetService("RunService").Heartbeat:Connect(function(dt)
if bKeyPressed then
local currTime = tick()
if currTime - prevTime >= updateTime then
updatePosition()
local currPos = part.Position
local velocity = (currPos - prevPos) / (currTime - prevTime)
part.Velocity = velocity
prevPos = currPos
prevTime = currTime
end
else
part.Velocity = Vector3.new()
end
end)
local UserInputService = game:GetService("UserInputService")
local function onInput(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.R and gameProcessedEvent == false then
while UserInputService:IsKeyDown(Enum.KeyCode.R) do
part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(3), 0)
wait()
end
print("The R key is no longer being held down.")
end
end
UserInputService.InputBegan:Connect(onInput)
event3.OnClientEvent:Connect(function(hitsize)
print(hitsize.Orientation)
part.Orientation = hitsize.Orientation
print(part.Orientation)
part = hitsize
print(part.Orientation)
local relativeRotation = CFrame.Angles(math.rad(90), 0, 0)
part.CFrame = hitsize.CFrame * relativeRotation
part.Transparency = .5
print(part.CFrame.lookVector)
end)
Oh gosh I’ve been trying to figure this out for hoooursss
ahhhhhhhhhhhHHhhhhhhhhh