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

Whenever i execute this it moves the rotation and position, but i only wanna move rotation???

Asked by 4 years ago
script.Parent.CFrame = CFrame.Angles(0, math.rad(45), 0)

2 answers

Log in to vote
1
Answered by
ScuffedAI 435 Moderation Voter
4 years ago
Edited 4 years ago

The reason to why your script doesn't work is because CFrame.Angles creates a blank data type, ONLY containing its rotation. In order to solve your problem, you need to multiply the current CFrame with the Rotation.

Like such:

script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0, math.rad(45), 0)
Ad
Log in to vote
0
Answered by
iuclds 720 Moderation Voter
4 years ago
Edited 4 years ago

Simple turn

local x = 1
local y = 1
local z = 1
while true do -- Loop
script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(x,y,z) -- Changes the orientation. 

More advaned turn

--//Locals\\--
local SpinSpeedx = 0.2 -- Higher is less smooth
local SpinSpeedy = 0.2 -- Lower = smooth
local SpinSpeedz = 0.2 -- Medium speed = Looks laggy
local SpinWait = 0.01 -- How long it waits to show the next frame
--//Script\\--
while true do
script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(SpinSpeedx,SpinSpeedy,SpinSpeedz) 
wait(SpinWait)
end

Answer this question