The barrels have a mind of their own.
(Above is random generation of the script below)
local BarrelAngleOffset = CFrame.Angles(0, 0, math.random(1, 360))
ChosenBarrel:SetPrimaryPartCFrame(ChosenBarrel:GetPrimaryPartCFrame() * BarrelAngleOffset)
I tried moving the math.random
part to the other axis’es(?) but I got the same results or the barrel just decides to fly away.
This is what I’m trying to do, by rotating it only on this axis.
2 Likes
You forgot to add math.rad()
in CFrame.Angles()
:
local BarrelAngleOffset = CFrame.Angles(0, 0, math.rad(math.random(1, 360)))
ChosenBarrel:SetPrimaryPartCFrame(ChosenBarrel:GetPrimaryPartCFrame() * BarrelAngleOffset)
CFrame.Angles()
and CFrame.fromEulerAnglesXYZ()
expects degree value in radians, so you have to convert normal angle to raidans using math.rad()
.
And here is the some information pictures:
2 Likes
I’m getting the error “Argument count mismatch. Function expects 1 argument, but 2 are specified”
local BarrelAngleOffset = CFrame.Angles(0, math.rad(math.random(1, 360), 0))
I moved around the math.rad because using your script it rotates on the wrong axis:
![d070bbe67d853f30f58ad440cb48ccad](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/4X/f/d/a/fdadc42fcb48b4ec22e590e111033e712870f134.png)
Bracket is misplaced, math.rad()
is now getting 2 values.
Fix:
local BarrelAngleOffset = CFrame.Angles(0, math.rad(math.random(1, 360)), 0)
1 Like
Thank you so much! I’m sorta blind, lol.
1 Like