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

Attempt to compare two userdata values?

Asked by 5 years ago
--local event = game.ReplicatedStorage.Remote.Mow
local event = script.Parent:WaitForChild("Events").Mow

event.OnServerEvent:Connect(function(plr, target)
    if target.Size > 0.2 then
        target.Size = target.Size - Vector3.new(0,0.1,0)
        target.CFrame = CFrame.new(target.Position - Vector3.new(0,0.05,0))
    else
        print(target.Size)
    end


end)

im bamboozled

1 answer

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

Hi dark,

The reason it's giving you that error is because the SIze is a Vector3 value, and you're comparing it to a Number value. So, I recommend to compare it to the Vector3 value.

Something like this:

--local event = game.ReplicatedStorage.Remote.Mow
local event = script.Parent:WaitForChild("Events").Mow

event.OnServerEvent:Connect(function(plr, target)
    if target.Size > Vector3.new(0, 0.2, 0) then
        target.Size = target.Size - Vector3.new(0,0.1,0)
        target.CFrame = CFrame.new(target.Position - Vector3.new(0,0.05,0))
    else
        print(target.Size)
    end


end)

Or, if you wanna compare only the y axis of the Size, then this is how you'd do it:

--local event = game.ReplicatedStorage.Remote.Mow
local event = script.Parent:WaitForChild("Events").Mow

event.OnServerEvent:Connect(function(plr, target)
    if target.Size.Y > 0.2 then
        target.Size = target.Size - Vector3.new(0,0.1,0)
        target.CFrame = CFrame.new(target.Position - Vector3.new(0,0.05,0))
    else
        print(target.Size)
    end


end)

Hope I helped and have a wonderful day/night.

Thanks,

Best regards,

~~ KingLoneCat

0
KING LONE, LONG TImE NO SEE DUDE :D greatneil80 2647 — 5y
0
Yeah, it's been a while. How's it going? KingLoneCat 2642 — 5y
Ad

Answer this question