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

How to i pass instances through a remote event?

Asked by 8 years ago

I am making a drag tool for filtering enabled, but i can't pass rays or instances (the part that i want to move) through a remote event. I managed to decompile the rays in to the six numbers, but i still cant grab the part.

before i separated the client and server, the grabber worked fine on solo mode, so the problem is with the remote events.

Here is my local script

function onMouseDown(mouse)
    if true then --ill change this to test for grab-able blocks later
        mouse.Icon ="rbxasset://textures\\GrabRotateCursor.png"
        part = mouse.Target
        local hitPoint = mouse.Hit:toObjectSpace(part.CFrame).p
        local instances = {part}
        script.Parent.Script.StartDrag:FireServer(part, hitPoint, instances)
    end
end

This is my Script

script.StartDrag.OnServerEvent:connect(function(mousePart, hitPoint, collection)
    if true then
        local part=mousePart
        dragger = Instance.new("Dragger")
        dragger:MouseDown(mousePart, hitPoint, collection)--This is line 8 where the error is from
        pcall(function()  end)
    end
end)

My error is

11:30:14.336 - Unable to cast value to Objects

11:30:14.337 - Script 'Players.Player1.Backpack.Drag.Script', Line 8

11:30:14.337 - Stack End

My question is how do i pass instance based variables like part IDs through remote events.

1 answer

Log in to vote
1
Answered by 8 years ago
script.StartDrag.OnServerEvent:connect(function(Player, Args)
    if true then

        local mousePart         =   Args['mousePart'];
        local hitPoint          =   Args['hitPoint'];
        local collection            =   Args['collection'];

        print(mousePart, hitPoint);

        local part              =   mousePart
            local dragger           =   Instance.new("Dragger")

            dragger:MouseDown(mousePart, hitPoint, collection)

        pcall(function()  
        end)
    end
end)
function onMouseDown(mouse)
    if true then
        mouse.Icon      =    "rbxasset://textures\\GrabRotateCursor.png"
        local part          =    mouse.Target
        local hitPoint      =    mouse.Hit:toObjectSpace(part.CFrame).p
        local instances         =    {part}

        local Args = {['mousePart'] = part, ['hitPoint'] = hitPoint, ['collection'] = instances};

        game:GetService("ReplicatedStorage").StartDrag:FireServer(Args)
    end
end
0
Well, i can now pass parts through remote events, but i still can't get the dragger to respond to them I think i know what to do now. Thanks CALEB2020 30 — 8y
0
I got the dragger working compleatly, thanks :) CALEB2020 30 — 8y
Ad

Answer this question