--Please help becuase i tried to make a script and i failed. please help me!
wait (2) local p = Instance.new("Part") p.Size = Vector3.new(1, 1, 1)--Size p.BrickColor = BrickColor.new("Mid gray") local cash = Instance.new("IntValue",part) cash.Name = "Cash" p.Position = script.Parent.Position p.Parent = game.Workspace p.Material = "Plastic" p.Reflectance = 0.0 p.Transparency = 0.0 p.Shape = "Block" wait(2) end end
Alright, this isn't very complex so I'll go ahead and put it in a code block for you;
wait (2) local p = Instance.new("Part") p.Size = Vector3.new(1, 1, 1)--Size p.BrickColor = BrickColor.new("Mid gray") local cash = Instance.new("IntValue",part) cash.Name = "Cash" p.Position = script.Parent.Position p.Parent = game.Workspace p.Material = "Plastic" p.Reflectance = 0.0 p.Transparency = 0.0 p.Shape = "Block" wait(2) end end
So first, before we even get to the errors, lets shorten this a bit. When you create a new Part, their properties are set to certain defaults. Material
is, by default, set to Plastic. Reflectance
and Transparency
are both set to 0. Shape
is set to Block. Therefore we can remove these lines to get;
wait (2) local p = Instance.new("Part") p.Size = Vector3.new(1, 1, 1)--Size p.BrickColor = BrickColor.new("Mid gray") local cash = Instance.new("IntValue",part) cash.Name = "Cash" p.Position = script.Parent.Position p.Parent = game.Workspace wait(2) end end
The first and most obvious error is your two end
s at the bottom. You only need to add an end
when you create a new scope (with the exception of repeat
loops). Here you do not create a new scope, so we can get rid of the end
s.
wait (2) local p = Instance.new("Part") p.Size = Vector3.new(1, 1, 1)--Size p.BrickColor = BrickColor.new("Mid gray") local cash = Instance.new("IntValue",part) cash.Name = "Cash" p.Position = script.Parent.Position p.Parent = game.Workspace wait(2)
Although it must be noted that putting a wait()
function at the end of your code is pointless, since nothing happens after it. We can also take out p.Parent = game.Workspace
and just use the second argument of Instance.new()
to set the parent.
wait (2) local p = Instance.new("Part", game.Workspace) p.Size = Vector3.new(1, 1, 1)--Size p.BrickColor = BrickColor.new("Mid gray") local cash = Instance.new("IntValue",part) cash.Name = "Cash" p.Position = script.Parent.Position
But look on line 5! There is no value named part
! That will definitely cause an error. We used p
for the Part variable, so we must use it consistently.
wait (2) local p = Instance.new("Part", game.Workspace) p.Size = Vector3.new(1, 1, 1)--Size p.BrickColor = BrickColor.new("Mid gray") local cash = Instance.new("IntValue", p) cash.Name = "Cash" p.Position = script.Parent.Position
And we might as well rearrange the Part editing with the Cash editing just for organization purposes.
wait (2) local p = Instance.new("Part", game.Workspace) p.Size = Vector3.new(1, 1, 1)--Size p.BrickColor = BrickColor.new("Mid gray") p.Position = script.Parent.Position local cash = Instance.new("IntValue", p) cash.Name = "Cash"
Now you have a functioning dropper! But wait, this will only run once. We need to use a while
loop, so it will run forever. We will make the while
loop's condition just the word true
, because the word true will never equal false. Therefore the loop will run forever. This time we will be creating a new scope, so don't forget an end
. Also remember to indent!
while true do wait (2) local p = Instance.new("Part", game.Workspace) p.Size = Vector3.new(1, 1, 1)--Size p.BrickColor = BrickColor.new("Mid gray") p.Position = script.Parent.Position local cash = Instance.new("IntValue", p) cash.Name = "Cash" end
--this is the real script -.-
while true do
wait (2) local p = Instance.new("Part", game.Workspace) p.Size = Vector3.new(1, 1, 1)--Size p.BrickColor = BrickColor.new("Mid gray") p.Position = script.Parent.Position local cash = Instance.new("IntValue", p) cash.Name = "Cash" cash.Value = 1
end