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

invalid argument #1 to 'rad' (number expected, got CFrame)?

Asked by
Jac_00b 157
3 years ago

Hello, I am having an error with this block of code:

function game.ReplicatedStorage.Build.OnServerInvoke(Player, Pos, ItemName, counter)
    local Item = game.ReplicatedStorage.Ores:FindFirstChild(ItemName):Clone()
    Item.PrimaryPart.CFrame = CFrame.new(Item.PrimaryPart.Position) * CFrame.Angles(0,math.rad(counter),0)
    return PlaceItem(Player, Pos, Item, counter)
end 

Basically, this is the server side to a rotation script (whenever you press r a model rotates by 45 degrees). Each model does a have primarypart. So everytime you press r, in the localscript, it increases a value by 45 (counter variable). You can see that I brought over the counter variable on the server invoke. So I tried putting the counter variable into a CFrame.Angles setup, and got the error. I don't know why this is happening as counter is saved as a number variable. Maybe the transition from local to server screwed it up? Any help would be appreciated.

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

math.rad expects a num as an argument, not a CFrame.

0
Sorry for the late response, but how is it a CFrame? The counter variable is simply a number stored in the script. I never added CFrame.new to it or anything. Jac_00b 157 — 3y
0
You state that you put the counter to a CFrame.Angles, is this correct? deeskaalstickman649 475 — 3y
Ad

Answer this question