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

Sending part info over Remote Function?

Asked by 4 years ago

I'm trying to essentially clone a part from a local script, and put it into the game. After reading this, https://devforum.roblox.com/t/sending-a-cloned-object-to-the-server-through-a-remote-event/347281/4

I learned it would probably be easier for me to just make a different part with essentially the same properties.

I've tried a .OnServerInvoke on a remote function, and a .OnServerEvent with a remote event. I don't think I'm transferring the info right? I've followed a few tutorials and looked at some blog posts and thought I'm doing it right but I guess not?

Local Script

                        local partsize = newpart.Size
                        local partposition = newpart.Position
                        local partcolor = newpart.Color
                        local partmaterial = newpart.Material
                        local partshape = newpart.Shape
                        game.ReplicatedStorage.brickplace:FireServer(partsize, partposition, partcolor, partmaterial, partshape)
                        newpart:destroy()

Server Script


game.ReplicatedStorage.brickplace.OnServerEvent:Connect(function(player, partsize, partposition, partcolor, partmaterial, partshape) local part = Instance.new("Part") part.Transparency = 0 part.Parent = game.Workspace part.Position = Vector3.new(partposition) part.Size = Vector3.new(partsize) part.Color = Color3.new(partcolor) end)

I'm not getting any errors, but the part being made is becoming essentially blank for all things. So the color is 0,0,0 (black) the size is is like 0.05,0.05,0.05, position is 0,0,0 etc

What exactly did I do wrong?

0
I would recommend looking over this https://devforum.roblox.com/t/how-to-save-parts-and-the-idea-of-serialization/524311 as it might help you because you can serialize the data and send it the the remove event. tjtorin 172 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

In the lines 5-7 in the server script, you're trying to set Vector3/Color3 using values that are already Vector3/Color3 values. What the script is doing is the equivalent of this:

part.Position = Vector3.new(Vector3.new(0,0,0))

The solution would be to remove Vector3.new/Color3.new when assigning the part's properties.

Server Script

game.ReplicatedStorage.brickplace.OnServerEvent:Connect(function(player, partsize, partposition, partcolor, partmaterial, partshape)
    local part = Instance.new("Part")
    part.Transparency = 0
    part.Parent = game.Workspace
    part.Position = partposition
    part.Size = partsize
    part.Color = partcolor
end)

I'd also recommend sending a table of values instead of multiple values at once

0
Thank you! barrettr500 53 — 4y
Ad
Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

Try removing the ".new" when setting a value. (e.g part.Size = partsize)

0
PFT im an idiot barrettr500 53 — 4y

Answer this question