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

Why am I getting an error telling me that I am attempting to perform an arithmetic on an Object?

Asked by
CVDev 2
4 years ago
Edited 4 years ago

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.

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? Ziffixture 6913 — 4y
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. Psudar 882 — 4y
0
Bit unrelated, but your round function won’t work perfectly. You’ll need to use math.floor instead of math.ceil. ihatecars100 502 — 4y
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. CVDev 2 — 4y

Answer this question