The part is not rotating and it gives me a strange error

I made localscript that should rotate model/part in the game but it just doesn’t

The output error:
image

Code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RotatePartsEvent = ReplicatedStorage:WaitForChild("RotateCapibaras")
local partToRotate = game.Workspace.DeliverySpots.Delivery.Deliver

local function rotateParts()

	local newRotation = partToRotate.CFrame * CFrame.Angles(0, math.rad(-90), 0)


	partToRotate.CFrame = newRotation
end


rotateParts()

its really strange why it does that.

The full script would help alot…

Sorry my bad. wrong script just realized.

local PickedUp = game.ReplicatedStorage.Events.Pickup:FindFirstChild("PickedUp")

PickedUp.OnClientEvent:Connect(function()
	local remote = game.ReplicatedStorage:FindFirstChild("RotateCapibaras")
	local player = game.Players.LocalPlayer
	local has = false
	game.SoundService.Sfx:FindFirstChild("MissionStarted"):Play()
	print("part visible for "..player.Name)
	game.Workspace.DeliverySpots.Delivery.Capybara_mesh.Transparency = 0
	game.Workspace.DeliverySpots.Delivery.Deliver.Script.Enabled = true
	game.Workspace.DeliverySpots.Delivery.Beam.Transparency = 0
	game.Workspace.DeliverySpots.Delivery.Deliverbillboard.WayPoint.ImageLabel.Visible = true
	game.Workspace.DeliverySpots.Delivery.Deliverbillboard.WayPoint.TextLabel.Visible = true
	wait()
	game.Workspace.PickUpSpots.PickUpSpot.Capybara_one.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot.Beam.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot.PickUpWayPoint.WayPoint.ImageLabel.Visible = false
	game.Workspace.PickUpSpots.PickUpSpot.PickUpWayPoint.WayPoint.TextLabel.Visible = false
	wait()
	game.Workspace.PickUpSpots.PickUpSpot2.Capybara_one.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot2.Beam.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot2.PickUpWayPoint.WayPoint.ImageLabel.Visible = false
	game.Workspace.PickUpSpots.PickUpSpot2.PickUpWayPoint.WayPoint.TextLabel.Visible = false
	wait()
	game.Workspace.PickUpSpots.PickUpSpot3.Capybara_one.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot3.Beam.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot3.PickUpWayPoint.WayPoint.ImageLabel.Visible = false
	game.Workspace.PickUpSpots.PickUpSpot3.PickUpWayPoint.WayPoint.TextLabel.Visible = false
	wait()
	game.Workspace.PickUpSpots.PickUpSpot5.Capybara_one.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot5.Beam.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot5.PickUpWayPoint.WayPoint.ImageLabel.Visible = false
	game.Workspace.PickUpSpots.PickUpSpot5.PickUpWayPoint.WayPoint.TextLabel.Visible = false
	
	wait()
	
	if not has then
		game.Workspace.DeliverySpots.Delivery.Deliver.Orientation.Y = -90
		game.Workspace.DeliverySpots.Delivery.Beam.Orientation.Y = -90
		game.Workspace.DeliverySpots.Delivery.Deliverbillboard.Orientation.Y = -90
		game.Workspace.DeliverySpots.Delivery.Capybara_mesh.Orientation.Y = -90
	else
		warn("no")
	end
end)

local Delivered = game.ReplicatedStorage.Events.Deliver:FindFirstChild("Delivered")

Delivered.OnClientEvent:Connect(function()
	local player = game.Players.LocalPlayer
	game.SoundService.Sfx:FindFirstChild("MissionEnded"):Play()
	print("part visible for "..player.Name)
	game.Workspace.DeliverySpots.Delivery.Capybara_mesh.Transparency = 1
	game.Workspace.DeliverySpots.Delivery.Deliver.Script.Enabled = false
	game.Workspace.DeliverySpots.Delivery.Beam.Transparency = 1
	game.Workspace.DeliverySpots.Delivery.Deliverbillboard.WayPoint.ImageLabel.Visible = false
	game.Workspace.DeliverySpots.Delivery.Deliverbillboard.WayPoint.TextLabel.Visible = false
	wait()
	game.Workspace.PickUpSpots.PickUpSpot.Capybara_one.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot.Beam.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot.PickUpWayPoint.WayPoint.ImageLabel.Visible = true
	game.Workspace.PickUpSpots.PickUpSpot.PickUpWayPoint.WayPoint.TextLabel.Visible = true
	wait()
	game.Workspace.PickUpSpots.PickUpSpot2.Capybara_one.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot2.Beam.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot2.PickUpWayPoint.WayPoint.ImageLabel.Visible = true
	game.Workspace.PickUpSpots.PickUpSpot2.PickUpWayPoint.WayPoint.TextLabel.Visible = true
	wait()
	game.Workspace.PickUpSpots.PickUpSpot3.Capybara_one.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot3.Beam.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot3.PickUpWayPoint.WayPoint.ImageLabel.Visible = true
	game.Workspace.PickUpSpots.PickUpSpot3.PickUpWayPoint.WayPoint.TextLabel.Visible = true
	wait()
	game.Workspace.PickUpSpots.PickUpSpot5.Capybara_one.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot5.Beam.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot5.PickUpWayPoint.WayPoint.ImageLabel.Visible = true
	game.Workspace.PickUpSpots.PickUpSpot5.PickUpWayPoint.WayPoint.TextLabel.Visible = true
end)

The Y property of a part Orientation is read-only, meaning you cant change it, also you shouldnt be using .Orientation you should be using CFrame.Angles

1 Like

So i tried but I’ve had another function that should change the position while rotating.

local PickedUp = game.ReplicatedStorage.Events.Pickup:FindFirstChild("PickedUp")

PickedUp.OnClientEvent:Connect(function()
	local pos = {
		Vector3.new(-240.519, 21.895, 471.281),
		Vector3.new(-240.519, 21.895, 412.211)
	}
	local remote = game.ReplicatedStorage:FindFirstChild("RotateCapibaras")
	local player = game.Players.LocalPlayer
	local has = false
	game.SoundService.Sfx:FindFirstChild("MissionStarted"):Play()
	print("part visible for "..player.Name)
	game.Workspace.DeliverySpots.Delivery.Capybara_mesh.Transparency = 0
	game.Workspace.DeliverySpots.Delivery.Deliver.Script.Enabled = true
	game.Workspace.DeliverySpots.Delivery.Beam.Transparency = 0
	game.Workspace.DeliverySpots.Delivery.Deliverbillboard.WayPoint.ImageLabel.Visible = true
	game.Workspace.DeliverySpots.Delivery.Deliverbillboard.WayPoint.TextLabel.Visible = true
	wait()
	game.Workspace.PickUpSpots.PickUpSpot.Capybara_one.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot.Beam.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot.PickUpWayPoint.WayPoint.ImageLabel.Visible = false
	game.Workspace.PickUpSpots.PickUpSpot.PickUpWayPoint.WayPoint.TextLabel.Visible = false
	wait()
	game.Workspace.PickUpSpots.PickUpSpot2.Capybara_one.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot2.Beam.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot2.PickUpWayPoint.WayPoint.ImageLabel.Visible = false
	game.Workspace.PickUpSpots.PickUpSpot2.PickUpWayPoint.WayPoint.TextLabel.Visible = false
	wait()
	game.Workspace.PickUpSpots.PickUpSpot3.Capybara_one.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot3.Beam.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot3.PickUpWayPoint.WayPoint.ImageLabel.Visible = false
	game.Workspace.PickUpSpots.PickUpSpot3.PickUpWayPoint.WayPoint.TextLabel.Visible = false
	wait()
	game.Workspace.PickUpSpots.PickUpSpot5.Capybara_one.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot5.Beam.Transparency = 1
	game.Workspace.PickUpSpots.PickUpSpot5.PickUpWayPoint.WayPoint.ImageLabel.Visible = false
	game.Workspace.PickUpSpots.PickUpSpot5.PickUpWayPoint.WayPoint.TextLabel.Visible = false
	
	wait()
	
	if not has then
		game.Workspace.DeliverySpots.Delivery.Deliver.CFrame = CFrame.Angles(0, -90, 0)
		game.Workspace.DeliverySpots.Delivery.Beam.CFrame = CFrame.Angles(0, -90, 0)
		game.Workspace.DeliverySpots.Delivery.Deliverbillboard.CFrame = CFrame.Angles(0, -90, 0)
		game.Workspace.DeliverySpots.Delivery.Capybara_mesh.CFrame = CFrame.Angles(0, -90, 0)
	else
		warn("no")
	end
	
	local randomIndex = math.random(1, #pos)
	local randomPosition = pos[randomIndex]
	game.Workspace.DeliverySpots.Delivery:SetPrimaryPartCFrame(CFrame.new(randomPosition))
	print("Did do done.")
end)

local Delivered = game.ReplicatedStorage.Events.Deliver:FindFirstChild("Delivered")

Delivered.OnClientEvent:Connect(function()
	local player = game.Players.LocalPlayer
	game.SoundService.Sfx:FindFirstChild("MissionEnded"):Play()
	print("part visible for "..player.Name)
	game.Workspace.DeliverySpots.Delivery.Capybara_mesh.Transparency = 1
	game.Workspace.DeliverySpots.Delivery.Deliver.Script.Enabled = false
	game.Workspace.DeliverySpots.Delivery.Beam.Transparency = 1
	game.Workspace.DeliverySpots.Delivery.Deliverbillboard.WayPoint.ImageLabel.Visible = false
	game.Workspace.DeliverySpots.Delivery.Deliverbillboard.WayPoint.TextLabel.Visible = false
	wait()
	game.Workspace.PickUpSpots.PickUpSpot.Capybara_one.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot.Beam.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot.PickUpWayPoint.WayPoint.ImageLabel.Visible = true
	game.Workspace.PickUpSpots.PickUpSpot.PickUpWayPoint.WayPoint.TextLabel.Visible = true
	wait()
	game.Workspace.PickUpSpots.PickUpSpot2.Capybara_one.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot2.Beam.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot2.PickUpWayPoint.WayPoint.ImageLabel.Visible = true
	game.Workspace.PickUpSpots.PickUpSpot2.PickUpWayPoint.WayPoint.TextLabel.Visible = true
	wait()
	game.Workspace.PickUpSpots.PickUpSpot3.Capybara_one.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot3.Beam.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot3.PickUpWayPoint.WayPoint.ImageLabel.Visible = true
	game.Workspace.PickUpSpots.PickUpSpot3.PickUpWayPoint.WayPoint.TextLabel.Visible = true
	wait()
	game.Workspace.PickUpSpots.PickUpSpot5.Capybara_one.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot5.Beam.Transparency = 0
	game.Workspace.PickUpSpots.PickUpSpot5.PickUpWayPoint.WayPoint.ImageLabel.Visible = true
	game.Workspace.PickUpSpots.PickUpSpot5.PickUpWayPoint.WayPoint.TextLabel.Visible = true
end)

```´

I mean is that how I use CFrame.Angles?

Uh you have to do the original cframe * CFrame.Angles()

oh yes my bad thanks wait let me try it

1 Like

I mean I tried that but still did not work.

use variables

local DeliverySpots = workspace:WaitForChild("DeliverySpots")
local Delivery = DeliverySpots.Delivery

local PickupSpots = workspace:WaitForChild("PickupSpots")
local PickUpSpot1, PickUpSpot2 = PickupSpots.PickupSpot1, PickupSpots.PickupSpot2

Delivery.Capybara_mesh.Transparency = 0
Delivery.Deliver.Script.Enabled = true
Delivery.Beam.Transparency = 0
Delivery.Deliverbillboard.WayPoint.ImageLabel.Visible = true
Delivery.Deliverbillboard.WayPoint.TextLabel.Visible = true

wait()

PickUpSpot1.Capybara_one.Transparency = 1
PickUpSpot1.Beam.Transparency = 1
PickUpSpot1.PickUpWayPoint.WayPoint.ImageLabel.Visible = false
PickUpSpot1.PickUpWayPoint.WayPoint.TextLabel.Visible = false

wait()

PickUpSpot2.Capybara_one.Transparency = 1
PickUpSpot2.Beam.Transparency = 1
PickUpSpot2.PickUpWayPoint.WayPoint.ImageLabel.Visible = false
PickUpSpot2.PickUpWayPoint.WayPoint.TextLabel.Visible = false

wait()

you could also use a function to toggle a PickUpSpot instead of going through each one

local function TogglePickup(PickupSpot, Show)
  local Capybara = PickupSpot.Capybara_one or PickupSpot.Capybara_mesh
  Capybara.Transparency = Show and 0 or 1
  PickupSpot.Beam.Transparency = Show and 0 or 1
  PickupSpot.PickUpWayPoint.WayPoint.ImageLabel.Visible = Show 
  PickupSpot.PickUpWayPoint.WayPoint.TextLabel.Visible = Show 
end

-- Loop through the PickupSpots and do TogglePickup() if it needs to be hidden
5 Likes

I appreciate it for helping so much! this games is a little funny game but thanks for helping my out of this!

2 Likes

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