Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

2 comments

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.

0

You state that you put the counter to a CFrame.Angles, is this correct?

This discussion is preserved as it was. New answers, comments, and votes are closed.