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???

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

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.

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