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

a simple mouse click detector script not working?

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

4 comments

0

can i ask what type of script you're using and where its located

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

0

I edited the post

0

Woah that's so weird. I saved the game and came back and the water part is gone???

1 answer

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

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