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 how to fix ??? [closed]

Asked by 4 years ago

This question already has an answer here:

ClickDetector is not a valid member of ClickDetector???

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)

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) Newh0hrizonCz 58 — 4y

Marked as Duplicate by User#29913, moo1210, and JesseSong

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 4 years ago

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" :)

Ad