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

Script keeps printing else even though it should be printing 'user has flask'?

So I'm making a water bottle filler thingamajig, and here's the code for the water bottle part

plate2.ClickDetector.MouseClick:Connect(function(Player)
	if Player.Character.hasflask == true then--This is the issue
		print('user has flask')
	wait()
		local val = Player.Character.flaskcolour
		fillingflask.Handle.Color = Color3.new(val)
		fount2.ParticleEmitter.Rate = 100
		fillingflask.Handle.Transparency = 0
		fillingflask.top.Transparency = 0
		fillingflask.seal.Transparency = 0
		fillingflask.black.Transparency = 0
	wait(5)
	fount2.ParticleEmitter.Rate = 0
		fillingflask.Handle.Transparency = 1
		fillingflask.top.Transparency = 1
		fillingflask.seal.Transparency = 1
		fillingflask.black.Transparency = 1
	else
	print('else')
		end
end)

All my values are in StarterCharacterScripts just in case you're wondering. This all worked before I added the code on line 2. By the way my output when I click the part is else

1 comment

0

Line 2: if player.Character.hasflask.Value == true then \ Line 5: local val = player.Character.flaskcolour.Value

1 answer

I assume that the has flask was not an external attribute of the character, but a value object. You need to change Line2, Line5 to:

----LINE 2
if Player.Character.hasflask.Value == true then
----LINE 5
local val = Player.Character.flaskcolour.Value

More details on value objects:Value_Objects(String).

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