door.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if hit.Parent:FindFirstChild("Humanoid") then
if Own.Value == "" then
door.CanCollide = false
Own.Value = tostring(player)
GUI.TextLabel.Text = player.Name.."'s tycoon"
wait(0.5)
end
if player.Name == Own.Value then
door.CanCollide = false
local dropper = game.Workspace.tycoon.tycoonHouse.Dropper
while true do
wait(1)
local part = Instance.new("Part", dropper)
part.Size = Vector3.new(1.2, 1, 1.2)
part.CFrame = dropper.dropperpart.CFrame * CFrame.new(0,-1.2,0)
part.Anchored = false
part.CanCollide = true
local Value = Instance.new("IntValue", part)
Value.Value = 5
Value.Name = "CashValue"
end
elseif player.Name ~=Own.Value then
door.CanCollide = true
print("GO AWAY SUCKER!!!")
end
local dropper = game.Workspace.tycoon.tycoonHouse.Dropper
end
end)
Why is the part creating created until the conveyor is flooded with part?
While loop is fine so I really don’t understand why is this happening.
cause door.Tunched:Connect(function(hit) is not fire only one
and when you return tunch door again the script will process and start while loop
add bool to make while loop only run one at time
local running = false
door.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if hit.Parent:FindFirstChild("Humanoid") then
if Own.Value == "" then
door.CanCollide = false
Own.Value = tostring(player)
GUI.TextLabel.Text = player.Name.."'s tycoon"
wait(0.5)
end
if player.Name == Own.Value then
door.CanCollide = false
local dropper = game.Workspace.tycoon.tycoonHouse.Dropper
if not running then
running = true
while true do
wait(1)
local part = Instance.new("Part", dropper)
part.Size = Vector3.new(1.2, 1, 1.2)
part.CFrame = dropper.dropperpart.CFrame * CFrame.new(0,-1.2,0)
part.Anchored = false
part.CanCollide = true
local Value = Instance.new("IntValue", part)
Value.Value = 5
Value.Name = "CashValue"
end
end
elseif player.Name ~=Own.Value then
door.CanCollide = true
print("GO AWAY SUCKER!!!")
end
local dropper = game.Workspace.tycoon.tycoonHouse.Dropper
end
end)