Socks347
(Socks347)
May 19, 2021, 8:58pm
#1
I am trying to make a lego trap chair, basically the placement works fine but the lego pegs don’t work
It places way under the ground
What it looks like:
How it should look:
Code:
– Variables
local RS = game:GetService('ReplicatedStorage')
local Event = RS:WaitForChild('PlaceBlock')
-- PlaceBlock Event
Event.OnServerEvent:Connect(function(plr,target,pos,Block, Block2)
local xBlock = Block:Clone()
local cBlock = Block2:Clone()
local model = xBlock
xBlock.Position = target.Position + pos
xBlock.Parent = game.Workspace
cBlock.Position = target.Position + pos
cBlock.Position = cBlock.Position + Vector3.new(0, cBlock.Position.Y + 0.488, 0)
cBlock.Parent = model
print(target)
end)
Galactiq
(Matthew)
May 19, 2021, 9:01pm
#2
Maybe try this. It seems like your positioning could be odd since it is changing it multiple times at once.
Event.OnServerEvent:Connect(function(plr,target,pos,Block, Block2)
local xBlock = Block:Clone()
local cBlock = Block2:Clone()
local model = xBlock
xBlock.Position = target.Position + pos
xBlock.Parent = game.Workspace
cBlock.Position = target.Position + pos + Vector3.new(0, 0.488, 0)
cBlock.Parent = model
print(target)
end)
Socks347
(Socks347)
May 19, 2021, 9:03pm
#3
Progress, it is now spawned inside the block instead of on top.
Galactiq
(Matthew)
May 19, 2021, 9:04pm
#4
Play around with that 0.488 number (increasingly) until it is the position you wish. That ought to do the trick!
Socks347
(Socks347)
May 19, 2021, 9:05pm
#5
Thank you, I have another issue though the main brick spawns under the map sometimes any ideas?
Galactiq
(Matthew)
May 19, 2021, 9:06pm
#6
Usually setting CFrame is better for placement systems, such as your own. I would take a look at the CFrame Documentation . Secondly, the parts should be anchored (I would think?). If they aren’t maybe try anchoring them so they aren’t strangely affected by physics/collisions.
Socks347
(Socks347)
May 19, 2021, 9:07pm
#7
They are anchored, and here is a example of them going threw the map. https://gyazo.com/c12c7311c5b31e7cf47b0f63bb442dff
Galactiq
(Matthew)
May 19, 2021, 9:09pm
#8
Were you in play mode? That video looked as if you were in studio flying around! Correct me if I am wrong. Anyways, you can add an offset on the Y axis (as I showed before with the stud parts) in order to ensure parts are fully above ground.
Socks347
(Socks347)
May 19, 2021, 9:10pm
#9
Yes, I was in play mode, thanks for the suggestion!
Socks347
(Socks347)
May 19, 2021, 9:11pm
#10
Wouldn’t a Y offset mess with it though, say the user is trying to place it on a more elevated part?
Galactiq
(Matthew)
May 19, 2021, 9:13pm
#11
You can use TargetSurface in order to determine which face of a part the user is hovering over.
Socks347
(Socks347)
May 19, 2021, 9:18pm
#12
I am currently using that and it does not work…