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

Score Click Gui?

Asked by 10 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: http://prntscr.com/2x6ihd ClicksGui to player script: http://prntscr.com/2x6imt ClicksGui Script: http://prntscr.com/2x6ivl The actual GUI: http://prntscr.com/2x6kvu And last but not least, the brick that changes your score each time you click it: http://prntscr.com/2x6j7i

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
0
Answered by 10 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)
end

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

button.ClickDetector.MouseClick:connect(onMouseClicked)
0
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. User#2 0 — 10y
0
Ah. I don't normally use ToString, thanks for the fixing. Edited AmericanStripes 610 — 10y
0
I tried testing the code. It doesn't seem to be working for me. Here's what it looks like after I fixed it: http://prntscr.com/2xcb6g (yes, there is a ClickDetector inside the part) McCorus 5 — 10y
0
Is there an Output? AmericanStripes 610 — 10y
View all comments (6 more)
0
Aswell, on Line 9, there appears to be a space after ". Value". Try to remove that space. AmericanStripes 610 — 10y
0
Nope. It says nothing in the output. McCorus 5 — 10y
0
Ahhh... It was hiding near the top. Here's what it says: http://prntscr.com/2xcse3 McCorus 5 — 10y
0
Read my newest edit AmericanStripes 610 — 10y
0
It works now! Thank you very very much for helping me resolve this problem! McCorus 5 — 10y
0
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 — 10y
Ad

Answer this question