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)

1part.Position = pos

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

01local Remote = game.ReplicatedStorage.wall
02 
03Remote.OnServerEvent:Connect(function(playerWhoFired, o ,pos, pos2, pos3)
04    local part = Instance.new("Part")
05    print("Fired")
06    part.Anchored = true
07    part.Size = Vector3.new(31.77, 16.8, 2)
08    part.Position = pos
09    part.Parent = game.Workspace
10    part.Name = "Wall"
11    part.BrickColor = BrickColor.new("Dark orange")
12    part.Material = Enum.Material.WoodPlanks
13end)

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

01local Remote = game.ReplicatedStorage.wall
02 
03Remote.OnServerEvent:Connect(function(playerWhoFired, o ,pos, pos2, pos3)
04    local part = Instance.new("Part")
05    print("Fired")
06    part.Anchored = true
07    part.Size = Vector3.new(31.77, 16.8, 2)
08    part.CFrame = CFrame.new(pos) -- changed line
09    part.Parent = game.Workspace
10    part.Name = "Wall"
11    part.BrickColor = BrickColor.new("Dark orange")
12    part.Material = Enum.Material.WoodPlanks
13end)
Ad

Answer this question