I am trying to round values up in a function. However, before I even call that function, I get an error telling me that I am trying to perform an arithmetic on an Object. I believe the script thinks that the function's parameter is a 'userdata value'. Here is the code:

Server Script:

local movePartEvent = game.ReplicatedStorage.MovePartEvent

local function round(X)
	return math.ceil(X + .50)
end

movePartEvent.OnServerEvent:Connect(function(...)	
	local tuppleArgs = {...}
	local player  = tuppleArgs[1]
	local value1  = tuppleArgs[2]
	local value2  = tuppleArgs[3]
	local value3  = tuppleArgs[4]
	
	game.Workspace.MovingPart.CFrame = CFrame.new(round(value1), 1, round(value3))
end)

Client Script:

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()

script.Parent.MouseButton1Click:Connect(function()
	print("Clicked")
	
	while true do 
		game.ReplicatedStorage.MovePartEvent:FireServer(player, (mouse.Hit.X), (mouse.Hit.Y), (mouse.Hit.Z))
		wait(0.50)
	end
end)

Thanks in advance!

Edit: I added the client script, although I don't think it has anything to do with my error. That is because I receive the error in my Server Script, on a function that I haven't even called yet.

4 comments

1

I feel like there is another piece to this that I should see, is there a LocalScript you could give me regarding the fired remote?

0

Yeah it looks like there may be something missing. I don't see any arithmetic (math) going on here! Do share! I'll check this tomorrow after school.

0

Bit unrelated, but your round function won’t work perfectly. You’ll need to use math.floor instead of math.ceil.

0

Hey guys. I just edited the question and gave you guys the Local Script. Also, it won't let me change 'Object' in the title to 'Userdata' value. Sorry.