Hi everyone, so I was working on my project when I encountered a problem, a part is not spawning. From what I could see, Instance.new("Part", game.Workspace) appears to not be working. Here’s the section of the scripts that aren’t working
This is just the section of the code that’s not working, I’ll be happy to send the full script if need be. For your information, the print functions all occur but the part just doesn’t even appear, not just transparent or parented to something else but just gone. Help would be greatly appreciated.
It may be that you’re missing one parameter from the RemoteEvent on the server. When you fire a remote event, you can pass variables through, but the first parameter you will receive is always the player.
Well, try setting the parent of the part only after you anchor and position it. It might be because it’s falling into the void, but I don’t see how that’s possible since no physics has happened before you anchor it. It could still be a fix though!
If you have have forgotten to include the player parameter, it would result you setting the position to something else because you reference another parameter
I’m not sure if this is what it’s supposed to be. I get the player variable from assuming that your server script is inside the tool. It works for me, but the blocks are spawning inside another. To fix that, you can use a script for surface, for example, in the remote parameter argument from localscript, use mouse.TargetSurface, then in the server script, use that argument like, if surface == Enum.NormalId.Front thenpart.Position = thisVector3
local character = script.Parent
local player = game.Players:GetPlayerFromCharacter(character)
script.Parent.BlockPlacedEvent.OnServerEvent:Connect(function(player,aString,value) -- assuming value is the mouse.Hit position argument that came through
print("SA")
local part = Instance.new("Part", game.Workspace)
print("C")
--part.Parent = game.Workspace (you are parenting it twice which is already in the new instance parameter)
print("W")
part.Anchored = true
local size = Vector3.new(4,4,4) --size (assuming the size is 4x4x4)
part.Size = size
part.Position = Vector3.new(math.floor(value.X / size.X) * size.X, value.Y + size.Y / 2, math.floor(value.Z / size.Z) * size.Z)
end)
It’s best if you don’t parent your part yet in the new instance parameter before anchoring it because if the server is fast, the block will fall before it gets anchored. Do your part.Anchored = true first then part.Parent = workspace. In the new instance, just do Instance.new(“Part”) without the parenting.
game.Workspace can be written in just workspace lowercase
Okay, wow, my guess 4x4x4 was right, and also value is the position you passed through. Just remove the parent inside your new instance. It’s working for me.