Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why can't I use a simple position command (probably compiler error)?

I passed on a variable that contains a part's position 'pos' and the remote event cant seem to do this (pos = part.Postion on script firing variable)

part.Position = pos

This must be an error and here is the rest of code for review

local Remote = game.ReplicatedStorage.wall

Remote.OnServerEvent:Connect(function(playerWhoFired, o ,pos, pos2, pos3)
	local part = Instance.new("Part")
	print("Fired")
	part.Anchored = true
	part.Size = Vector3.new(31.77, 16.8, 2)
	part.Position = pos
	part.Parent = game.Workspace
	part.Name = "Wall"
	part.BrickColor = BrickColor.new("Dark orange")
	part.Material = Enum.Material.WoodPlanks
end)

1 answer

roblox automatically tries to make no parts collide when the Position property is set, same with Size and Orientation. the simple fix is to operate on the CFrame instead of the Position or Orientation property after setting the size

local Remote = game.ReplicatedStorage.wall

Remote.OnServerEvent:Connect(function(playerWhoFired, o ,pos, pos2, pos3)
    local part = Instance.new("Part")
    print("Fired")
    part.Anchored = true
    part.Size = Vector3.new(31.77, 16.8, 2)
    part.CFrame = CFrame.new(pos) -- changed line
    part.Parent = game.Workspace
    part.Name = "Wall"
    part.BrickColor = BrickColor.new("Dark orange")
    part.Material = Enum.Material.WoodPlanks
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.