for i,v in pairs(script.Parent.Essentials:GetChildren()) do
local Owner = script.Parent.Owner
if v.Name == "PartCollector" then
v.Touched:connect(function(Part)
if Part:FindFirstChild('Cash') then
if Owner.Value ~= nil then
local player = Owner.Value
local gamepasses = player:WaitForChild("Gamepasses")
if gamepasses["Auto Collect Cash"].Value == true then
local playerMoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
if playerMoney ~= nil then
playerMoney.Value = playerMoney.Value + (Part.Cash.Value * gamepasses.Cash.Value)
end
elseif gamepasses["Auto Collect Cash"].Value == false then
Money.Value = Money.Value + (Part.Cash.Value * gamepasses.Cash.Value)
Debris:AddItem(Part,0.1)
end
end
end
end)
end
end
And it isn’t working.
The collector will collect stuff, but it won’t add to my CurrencyToCollect value. I think the gamepasses variable is not working, but correct me if I am wrong.
If you find the place that makes the script not work, please let me know!
Btw you shouldn’t look for gamepass that way, you wrote player:FindFirstChild(“Gamepasses”) wich is I think wrong
At the start of the script you should write
gamepass = game:GetService(“MarketPlaceService”)
And instead of :
player:FindFirstChild(“Gamepasses”)
if gamepasses[“AutoCollect Cash”].Value == true then
You should write :
if gamepass:UserOwnsGamePassAsync(player.UserId,GamepassID) then
If you aren’t receiving any errors in the output then it would help to add print statements around your code to isolate a source of error for us to be able to help you in the first place, either to confirm the existence or value of something or that points of your code are getting reached. The most that can be done here is guessing and assuming which is not very productive.
It seems like the owner is found, and so is the player.
Only problem is, the collector won’t collect. Here is my code:
for i,v in pairs(script.Parent.Essentials:GetChildren()) do
local Owner = script.Parent.Owner
if v.Name == "PartCollector" then
v.Touched:connect(function(Part)
if Part:FindFirstChild('Cash') then
if Owner.Value ~= nil then
print("Owner found")
local player = Owner.Value
local gamepasses = player:WaitForChild("Gamepasses")
if player and gamepasses["Auto Collect Cash"].Value == true then
print(player.Name.." was found, and the gamepass' value is true")
local playerMoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
if playerMoney ~= nil then
playerMoney.Value = playerMoney.Value + (Part.Cash.Value * gamepasses.Cash.Value)
else
error("Player's money was not found")
end
elseif player and gamepasses["Auto Collect Cash"].Value == false then
print(player.Name.." was found, and the gamepass' value is false")
Money.Value = Money.Value + (Part.Cash.Value * gamepasses.Cash.Value)
Debris:AddItem(Part,0.1)
elseif not player then
error("Could not find the player")
end
else
error("Owner not found")
end
end
end)
end
end
I did not have the gamepass bool value set to true. Just remember, the Money variable is the CurrencyToCollect value.
@Anton00k oh, I think you thought of the thing where you collect the money. It’s the processor that I’m talking about, the code right above those lines.
That made me wonder. I just noticed this, but the values are all set to 0, but if you have a gamepass the value goes up 2. That is why no cash is earned even though the collector collects it.
Yes I found it. The gamepass handler didn’t do anything to the values unless you had the gamepass. I tested it out with the value at 1 and it worked. When I tested it with 1 billion, it errored.
Do you need help with whatever you are trying to fix? If not, then please check the box “Solution” on the reply that helped you solve it, so others know that this post was solved and answered