Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I'm getting errors with CFrame of Region3's and dont know what it means?

Asked by
KDarren12 705 Donator Moderation Voter
4 years ago
Edited 4 years ago

I was messing around with Region3 since I'm fairly new, and I stumbled upon this error: "CFrame can not be assigned to" -- line 4 in this code:

local pos1,pos2 = Vector3.new(0,0,0), Vector3.new(20,20,20)
local R3 = Region3.new(pos1,pos2)
game:GetService("RunService").Stepped:Connect(function()
R3.CFrame = plr.Character.Torso.CFrame + Vector3.new(0,20,20)
for _,Part in pairs(game.Workspace:FindPartsInRegion3(R3,workspace.Base,math.huge)) do
Part.CanCollide = false
Part.Position = Part.Position + Vector3.new(math.random(1,10),math.random(1,5),math.random(1,10))
end
end)

(yes, I do have a plr variable." Any help is appreciated in advance!

0
The Region3 CFrame and Size properties are read only. Also don't name your variable Region3 since it's a built in one and you overwrite it. Change the casing, or rename it. User#24403 69 — 4y
0
so how would i size it? KDarren12 705 — 4y
0
or move its position KDarren12 705 — 4y
0
You don't. What exactly are you wanting to make? User#24403 69 — 4y
0
i want to make it so all parts in front of me go to a random position KDarren12 705 — 4y

1 answer

Log in to vote
-1
Answered by
sheepposu 561 Moderation Voter
4 years ago

I've never tried anything like this but I think know the problem. See if this works

local pos1,pos2 = Vector3.new(0,0,0), Vector3.new(20,20,20)
local R3 = Region3.new(pos1,pos2)
game:GetService("RunService").Stepped:Connect(function()
R3.CFrame = plr.Character.Torso.CFrame + CFrame.new(Vector3.new(0,20,20))
for _,Part in pairs(game.Workspace:FindPartsInRegion3(R3,workspace.Base,math.huge)) do
Part.CanCollide = false
Part.Position = Part.Position + Vector3.new(math.random(1,10),math.random(1,5),math.random(1,10))
end
end)

0
"Vector3 expected, got CFrame" idk what's happening. Thanks for the effort though! KDarren12 705 — 4y
0
Alright, that just means that the addition part is correct, but there is a problem assigning the value sheepposu 561 — 4y
0
It's possible that you can't change the CFrame sheepposu 561 — 4y
0
You didn't change a thing. User#24403 69 — 4y
0
Yes, if you look at line 4, I added plus CFrame.new rather than just a Vector3.new sheepposu 561 — 4y
Ad

Answer this question