Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Button To Turn AutoCollect Off Not Working, how do i do???

Asked by
Hafrew 16
3 years ago
Edited 3 years ago

the autocollect: ON button works, but the autocollect: OFF does not. I am using a zednov's tycoon kit but i customized it so that i can autocollect. the snippet from the tycoon core:

--Parts that fall into the collector(s) get processed
    for i,v in pairs(script.Parent.Essentials:GetChildren()) do
        if v.Name == "PartCollector" then
            v.Touched:connect(function(Part)
                local player = script.Parent.Owner.Value
                if Part:FindFirstChild('Cash') then
                if script.Parent.Parent.Parent.AutoCollect.Value == true then
            game.ServerStorage.PlayerMoney:FindFirstChild(player.Name).Value = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name).Value + Part.Cash.Value
            elseif script.Parent.AutoCollect.Value == false then
                    Money.Value = Money.Value + Part.Cash.Value
            end
                    Debris:AddItem(Part,0.1)
                end
            end)
        end
    end


the snippet from the GUI(which seems to be working but just putting it in here to be sure):

script.Parent.MouseButton1Click:Connect(function(fart)
    game.Workspace.HafrewsTycoonKit.AutoCollect.Value=false
    script.Parent.Parent.Autocollect.Text=("Autocollect:Off")
end)

please help me, and an advance THANK YOU!!!

0
Please put your code into a code block, it makes it a whole lot easier to read! It also helps us to paste your code to test it ingame. RazzyPlayz 497 — 3y
0
ok, i did that Hafrew 16 — 3y
0
i suggest you not take other people's code unless you can understand it, if you do not understand this, then please study these things so you can understand it and fix it yourself, use scripting helpers as a last resort if you cannot find anything or figure it out. AlexanderYar 788 — 3y
0
also are there any errors? if so please post them AlexanderYar 788 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I dont know if this will work, but try making the value false (Add an extra line):

--Parts that fall into the collector(s) get processed
    for i,v in pairs(script.Parent.Essentials:GetChildren()) do
        if v.Name == "PartCollector" then
            v.Touched:connect(function(Part)
                local player = script.Parent.Owner.Value
                if Part:FindFirstChild('Cash') then
                if script.Parent.Parent.Parent.AutoCollect.Value == true then

            script.Parent.Parent.Parent.AutoCollect.Value = false

            game.ServerStorage.PlayerMoney:FindFirstChild(player.Name).Value = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name).Value + Part.Cash.Value
            elseif script.Parent.AutoCollect.Value == false then
                    Money.Value = Money.Value + Part.Cash.Value
            end
                    Debris:AddItem(Part,0.1)
                end
            end)
        end
    end


0
(line 09 is the line i added in) AlexanderYar 788 — 3y
0
thanks it works Hafrew 16 — 3y
0
please accept my answer since it worked AlexanderYar 788 — 3y
0
PLEASE, IF IT WORKS ACCEPT MY ANSWER AlexanderYar 788 — 3y
View all comments (2 more)
0
i DID Hafrew 16 — 3y
0
I SAID THAT 9 DAYS AGO, YOU DID NOT ACCEPT MY ANSWER UNTIL 8 DAYS LATER AlexanderYar 788 — 3y
Ad

Answer this question