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

1local partsize = newpart.Size
2local partposition = newpart.Position
3local partcolor = newpart.Color
4local partmaterial = newpart.Material
5local partshape = newpart.Shape
6game.ReplicatedStorage.brickplace:FireServer(partsize, partposition, partcolor, partmaterial, partshape)
7newpart:destroy()

Server Script

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

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:

1part.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

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

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