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

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

Asked by
chafava -113
5 years ago

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

Log in to vote
0
Answered by 5 years ago

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)
Ad

Answer this question