So,im trying to do a building script that doesn't use decimals,more precisely but the error is:
bad argument #3 to 'Position' (Vector3 expected, got Number)
here's the script:
Player = script.Parent.Parent.Parent.Parent.Parent.Parent Mouse = Player:GetMouse() function Build() if Mouse.Target.Parent.Name == "Cell" then if Mouse.Target.Parent.Shrine.ShrineOrb.Owner.Value == Player.Name then print ("This Is Your Base,Building...") local Part = Instance.new("Part", game.Workspace.BuildenBlocks) Part.Name = "BuildenBlock" local MouseCFrame = Mouse.Hit print (MouseCFrame.p) Part.Anchored = true local x1 = math.floor(MouseCFrame.x) local y1 = math.floor(MouseCFrame.y) local z1 = math.floor(MouseCFrame.z) print (x1) print (y1) print (z1) Part.Position = (x1 + y1 + z1) Part.Rotation = Vector3.new(0,0,0) else print ("This Is Not Your Base,Build Cancelled") end end end Mouse.Button1Down:connect(Build)
Alright, well it's quite simple to solve the issue you've ran into. Let's say that x1 is 5, y1 is 3, and z1 is 7. What you're doing is:
Part.Position = (x1 + y1 + z1)
That's the same as doing:
Part.Position = (5 + 3 + 7)
and finally:
Part.Position = 15
Position requires a Vector3 value. What you're doing is just adding three numbers which isn't a Vector3 value. Here's your script fixed:
Player = script.Parent.Parent.Parent.Parent.Parent.Parent Mouse = Player:GetMouse() function Build() if Mouse.Target.Parent.Name == "Cell" then if Mouse.Target.Parent.Shrine.ShrineOrb.Owner.Value == Player.Name then print ("This Is Your Base,Building...") local Part = Instance.new("Part", game.Workspace.BuildenBlocks) Part.Name = "BuildenBlock" local MouseCFrame = Mouse.Hit print (MouseCFrame.p) Part.Anchored = true local x1 = math.floor(MouseCFrame.x) local y1 = math.floor(MouseCFrame.y) local z1 = math.floor(MouseCFrame.z) print (x1) print (y1) print (z1) Part.Position = Vector3.new(x1,y1,z1) -- That creates a new Vector3 value and sets the x value to x1, y value to y1, and z value to z1. Part.Rotation = Vector3.new(0,0,0) else print ("This Is Not Your Base,Build Cancelled") end end end Mouse.Button1Down:connect(Build)
Hope I helped! :)
On line 20 you are trying to set the position of a part, but you forgot to add Vector3.new before (x1 + y1 + z1) also, if you are setting values, you dont add them together you put commas inbetween like so
Part.Position = Vector3.new(x1,y1,z1) -- If you try to add them together, it is not a valid position as it doesnt say where x is, where y is, and where z is