Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ClickDetector is not a valid member of ClickDetector how to fix ???

I'm trying to make a hatching pet system but there seems to be an error but on the tutorial that I am watching it it's working perfectly fine

Here is the script

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 comment

0

your syntax is incorrect, use 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)

1 answer

your syntax is incorrect use:

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)

if the answer helped you, don't forget to mark it as "answered" :)

This discussion is preserved as it was. New answers, comments, and votes are closed.