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

a simple mouse click detector script not working?

Asked by 4 years ago
Edited 4 years ago
local sp = script.Parent
local waterSound = sp.Water
local emitter = sp.Water.ParticleEmitter

function Faucet()
    print("3")
    if emitter.Enabled then
        print("3=2")
        emitter.Enabled = false
        waterSound:Stop()
    else
        print("32")
        emitter.Enabled = true
        waterSound:Play()
    end
end


sp.Faucet.ClickDetector.MouseClick:connect(Faucet)

Error: Water is not a valid member of Model

the script's parent is the model and inside the model is Water and Faucet

0
can i ask what type of script you're using and where its located ArtBlart 533 — 4y
0
It's a script and the script is located in a part the part is a child of another part that has the clickdetector that is why it's sp.Parent jamespringles 105 — 4y
0
I edited the post jamespringles 105 — 4y
0
Woah that's so weird. I saved the game and came back and the water part is gone??? jamespringles 105 — 4y

1 answer

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

Hello, try this. It worked in my studio perfectly

local det = script.Parent.ClickDetector
local ep = script.Parent.ParticleEmitter
local sp = script.Parent.Water

det.MouseClick:connect(function()
    print('3')
    if ep.Enabled == false then
        print('3=2')
        ep.Enabled = true
        sp:Play()
    else
        print('32')
        sp:Stop()
        ep.Enabled = false
    end
end)

I hope this helps you out! Edit: this is a ServerScript inside the model

Ad

Answer this question