Hello developers, I hope you are having an amazing day! We are posting this thread again after not getting much help earlier. Me and a friend are trying to create a tycoon to learn more about scripting and game creation and have come upon an issue in our script. The issue comes from a button for the tycoon. The button has many copies when we look in the files and we do not know why. We have no idea why it is spawning so many, how do we fix it so that it only creates one?
The following are 2 different scripts:
auto dropper script: baseplate = script.Parent
debounce = false
baseplate.Touched:Connect(function(hit)
local ownsautodropper = game.ServerStorage.Ownsautodropper
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum ~= nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.Team == game.Teams["Purple Tycoon"] then
if player.leaderstats.Cash.Value >= 50 and debounce == false then
debounce = true
baseplate.Parent:Destroy()
print("you have enough")
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 50
local autodropper = workspace.Folder["F1 dropper 1"]:Clone()
autodropper.Parent = workspace.Objectscreated
local f = autodropper.dropperbase
f.Rotation = Vector3.new(0, 0, 0)
autodropper:SetPrimaryPartCFrame(CFrame.new(Vector3.new(-136.612, 501.442, -505.756)))
ownsautodropper.Name = "Ownsautodropper"
ownsautodropper.Value = true
local doubledropper = workspace.Folder["DoubleDropper - 250"]:Clone()
doubledropper.Parent = workspace.Folder
doubledropper:SetPrimaryPartCFrame(CFrame.new(Vector3.new(-127.598, 499.006, -518.544)))
doubledropper.Head.Rotation = Vector3.new(0, 0, -90)
wait(5)
debounce = false
else
print("not enough money")
end
end
end
end)
- begin working script:
baseplate = script.Parent
debounce = false
baseplate.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
print("hi")
if hum ~= nil and debounce == false then
local beganworking = Instance.new("BoolValue", game.ServerScriptService)
beganworking.Name = "Beganworking"
beganworking.Value = true
local dropper =workspace["F1 dropper"]:Clone()
dropper.Parent = workspace.Folder
dropper:SetPrimaryPartCFrame(CFrame.new(Vector3.new(-149.197, 501.37, -511.637)))
local conveyer = workspace["F1 Conveyor"]:Clone()
conveyer.Parent = workspace.Folder
conveyer.Position = Vector3.new(-117.5, 498.956, -511.718)
local destroyer = workspace.destroyer:Clone()
destroyer.Parent = workspace.Folder
destroyer.Position = Vector3.new(-85.389, 498.899, -511.755)
local wallone = workspace.Folder.destroyerwall:Clone()
wallone.Parent = workspace.Folder
wallone.Position = Vector3.new(-85.437, 499.345, -508.449)
local walltwo = workspace.Folder.destroyerwall2:Clone()
walltwo.Parent = workspace.Folder
walltwo.Position = Vector3.new(-85.416, 499.35, -514.919)
local wallthree = workspace.Folder.destroyerwall3:Clone()
wallthree.Parent = workspace.Folder
wallthree.Position = Vector3.new(-82.631, 499.34, -511.684)
local autodropperbutton = workspace.Folder["Auto Dropper - 50"]:Clone()
autodropperbutton.Parent = workspace.Folder
autodropperbutton:SetPrimaryPartCFrame(CFrame.new(Vector3.new(-137.8, 498.958, -519.212)))
autodropperbutton.Head.Rotation = Vector3.new(0, 0, -90)
baseplate.Parent:Destroy()
wait(5)
end
end)