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

How to Change Rotation on Enter?

Asked by 9 years ago

I am trying to make a script where when someone enters the game it changes rotation. But apparently there is an error on line 2. This is a regular script in a leaf (part).

game.Players.PlayerAdded:connect(function()
    game.Workspace.Leaf.Rotation = (math.random(), math.random(), math.random()) -- The output says Error in script: ')' expected near ',' but I have no idea what is wrong with it.
end)
0
let me see raystriker6707 30 — 9y

1 answer

Log in to vote
1
Answered by
RoboFrog 400 Moderation Voter
9 years ago

I'm pretty sure the issue comes in with the use of Rotation. You would be much better off using CFrame.

I would instead do this --

local leaf = game.Workspace.Leaf

leaf.CFrame = CFrame.new(leaf.CFrame.x, leaf.CFrame.y, leaf.CFrame.z) * CFrame.Angles(math.random(), math.random(), math.random()) -- you have to include the .new portion, so that will keep it in the same position while changing its rotation.

I've not tested that, but I'm pretty sure it would work. If it doesn't, let me know.

0
Omg. Thanks it worked. raystriker6707 30 — 9y
0
I'm glad that it helped! RoboFrog 400 — 9y
Ad

Answer this question