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

Score Click Gui?

Asked by 9 years ago

Alright, so here's what I'm trying to do.

Whenever someone would click this certain brick, their 'score' in a GUI I made would go up by 1 each time they click the brick. For some reason, I cannot get this to work.

Also, there's two TextLabels where the score is supposed to show. One is just plain white, the other is just a shadow to make it fancy.

Also, I'd like for the score to first be changed in a NumberValue and then the two TextLabels be equal to whatever the NumberValue is set to. This way, I can use the Data Store later for automatic score saving.

Anyways, here's some screenshots:

ClicksGui Hierarchy: ClicksGui to player script: ClicksGui Script: The actual GUI: And last but not least, the brick that changes your score each time you click it:

Hopefully my question (second 'paragraph' from top - it's not structured like a sentence but you know what I mean) is clear and understandable. Thank you in advanced!

1 answer

Log in to vote
Answered by 9 years ago

On this screenshot, not really sure which it is, there doesn't seem to be an actually script in there. That would be the problem.

Unless your question is, how you would go about it. In that case we would use the following;

--[[ First, we need to change 'score.' From my experience, having ".Value" in a variable just doesn't seem to work. That may or may not be the case, but just for safety, I would recommend removing the .Value from the variable.

**Same thing with the ".Text".


local text1 = --Put the "ClicksNumLabelText line here, without the .Text
local text2 = --Same thing, but with the Shadow one

local score = script.ClicksNum

function onMouseClick(click)
    score.Value = score.Value + 1
    text1.Text = tostring(score.Value)
    text2.Text = tostring(score.Value)

-- And here is where you would have the connect

NOTE: The above script has not, in any way, been tested. It is rough code, and with that, you are bound to find bugs.

Change your connect line (14) to:

ToString is a function (and is case sensitive, so it's "tostring") not a method. Change the "score.Value:ToString()"s to "tostring(score.Value)" and that should work, assuming text1 and text2 are filled in. Everesty 1006 — 9y
Ah. I don't normally use ToString, thanks for the fixing. Edited AmericanStripes 610 — 9y
I tried testing the code. It doesn't seem to be working for me. Here's what it looks like after I fixed it: (yes, there is a ClickDetector inside the part) McCorus 5 — 9y
Is there an Output? AmericanStripes 610 — 9y
View all comments (6 more)
Aswell, on Line 9, there appears to be a space after ". Value". Try to remove that space. AmericanStripes 610 — 9y
Nope. It says nothing in the output. McCorus 5 — 9y
Ahhh... It was hiding near the top. Here's what it says: McCorus 5 — 9y
Read my newest edit AmericanStripes 610 — 9y
It works now! Thank you very very much for helping me resolve this problem! McCorus 5 — 9y
Okay nevermind. For some reason it works in studio solo mode but it doesn't work in online mode. Should I change it to a localscript? McCorus 5 — 9y

Answer this question