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

ClickDetector is not a valid member of ClickDetector???

Asked by 4 years ago
Edited 4 years ago

This is the script and I'm just watching a tutorial but it ain't working help???

How to fix, please???

local cost = 500

local PetModule = require(game.ServerScriptService:WaitForChild("PetModule"))

script.Parent.ClickDetector.MouseClick:connect(function(player)

if player.leaderstats.Cash.Value >= cost then

   player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 500  

    local pet  = PetModule.chooseRandomPet()

    print(pet.Name.." selected")

end

end)

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You are referring to the ClickDetector as script.Parent.ClickDetector. It is probably script.Parent. Code:

local cost = 500

local PetModule = require(game.ServerScriptService:WaitForChild("PetModule"))

script.Parent.MouseClick:connect(function(player)

    if player.leaderstats.Cash.Value >= cost then

       player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 500 
        local pet  = PetModule.chooseRandomPet()

        print(pet.Name.." selected")

    end
end)

Happy to help, b_mni.

Ad

Answer this question