I am trying to make a dropper drop things, and the script I am using to do it is disabled, but not marking as a script. Why is this?
My code for the enabling script:
--Hide all machines by default
for i, v in script.Parent.Parent.Machines.Buyables:GetChildren() do
for index, child in pairs(v:GetChildren()) do
if child:IsA("WedgePart") or child:IsA("BasePart") or child:IsA("Part") then
child.Transparency = 1
child.CanCollide = false
end
end
end
for i, v in pairs(script.Parent.Parent.Machines.Buttons:GetChildren()) do
v.Transparency = 1
v.CanCollide = false
v.CanTouch = false
v.BillboardGui.Enabled = false
v.BillboardGui.TextLabel.Text = v.HoverText.Value.." - "..tostring(v.Price.Value).."$"
end
script.Parent.Parent.Machines.Buttons:WaitForChild("1").Transparency = 0
script.Parent.Parent.Machines.Buttons:WaitForChild("1").CanCollide = true
script.Parent.Parent.Machines.Buttons:WaitForChild("1").CanTouch = true
script.Parent.Parent.Machines.Buttons:WaitForChild("1").BillboardGui.Enabled = true
--Main
for i, v in pairs(script.Parent.Parent.Machines.Buttons:GetChildren()) do
--Setup Buttons
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
print("Hit!")
--We have a player
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
local leaderstats = plr:WaitForChild("leaderstats")
if leaderstats.Cash.Value >= v.Price.Value then
print("Can afford")
if not v:IsA("BoolValue") then
if not v:IsA("Script") then
v.CanCollide = false
v.Transparency = 1
end
end
leaderstats.Cash.Value -= v.Price.Value
if not v:IsA("Script") then
if not v:IsA("BoolValue") then
v.CorrespondingObject.Value.Handler.Enabled = true
end
end
for index, value in pairs(v.CorrespondingObject.Value:GetChildren()) do
if not value:IsA("BoolValue") then
if not v:IsA("Script") then
value.Transparency = 0
value.CanCollide = true
end
end
end
v.CanCollide = false
v.Transparency = 1
v.CanTouch = false
v.BillboardGui.Enabled = false
if v.CorrespondingButton.Value ~= nil then
v.CorrespondingButton.Value.Transparency = 0
v.CorrespondingButton.Value.CanTouch = true
v.CorrespondingButton.Value.CanCollide = true
v.CorrespondingButton.Value.BillboardGui.Enabled = true
end
end
end
end)
end
My code for the disabled script:
local isDropper = script.Parent.isDropper.Value
while true do
wait(2)
if isDropper then
local part = Instance.new("Part")
part.Size = Vector3.new(1,1,1)
part.Orientation = Vector3.new(0,0,0)
part.Material = Enum.Material.SmoothPlastic
part.BrickColor = script.Parent.isDropper.PartColor.Value
part.Anchored = false
part.CanCollide = true
local val = script.Parent.isDropper.PartValue:Clone()
val.Parent = part
part.Parent = workspace
end
end
My files in the explorer:
Img 1:
Img 2:
Thanks!