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

How to check if previously entered?

local Player = script.Parent.Parent.Parent.Parent.Parent.Parent

script.Parent.FocusLost:connect(function(enterPressed)
    if enterPressed and script.Parent.Text == "123" and Player:LoadBoolean("testing") == false then
        Player.Points.Value = Player.Points.Value + 10000
        Player:SaveBoolean("testing", true)

    elseif enterPressed and script.Parent.Text ~= "123" then
        script.Parent.Text = "Incorrect Code"

    elseif enterPressed and script.Parent.Text == "123" and Player:LoadBoolean("testing") == true then
        script.Parent.Text = "You have already entered Code"
    end
end)

Ok, so I have this and if the player writes something other than 12345 it says Incorrecr code, but when they enter 12345 it dosent give them the points, and if they enter 12345 again it dosent say You have already entered Code. Do I need to change the way the if statements are placed? Inside normal script

1 answer

...

EDIT:

  • Spent so much time on this answer too... :'c

Okay. Since you changed the Question, I have to change the Answer.... -Sigh-

I read your code, and I believe the problem is with your use of "if statements". If you replace all the "if"s except the first one with "elseif"s, and remove a few "end"s, I think it SHOULD work, but if it doesn't, don't hate me please. :(

I tried to fix it FOR you, not sure of the outcome...

local Player = game.Players.LocalPlayer

script.Parent.FocusLost:connect(function(enterPressed)
	if enterPressed and script.Parent.Text == "12345" and Player:LoadBoolean("test3") == false then
		Player.Points.Value = Player.Points.Value + 10000
		Player:SaveBoolean("test3", true)
		
	elseif enterPressed and script.Parent.Text ~= "12345" then
		script.Parent.Text = "Incorrect Code"
		
	elseif enterPressed and script.Parent.Text == "12345" and Player:LoadBoolean("test3") == true then
		script.Parent.Text = "You have already entered Code"
	end
end)

Well, like LAST time, I hope this helps solve your problem. And you might need a harder code then 12345... Bye. :)

  • Kratos232

18 comments

0

The money saves, etc but i would like a dif code every week, so they can only enter say code 123 once then they have to wait for next week to enter in the next code? Do I just change the saveboolean to be likehasEnteredCode1, then hasEnteredCode2?

0

Thanks for all the ways. I can rate up, but cant accept till i actually test which wont be till tomorrow

0

I guess you could, or you could make a time system using tick(), but I guess that'd be weird. :P

0

I have editted my question with what I am trying to test, please look at it

0

I had to edit my answer, sorry. I think it should work with that.

0

My code isnt gonna be 12345 :p just for testing purposes

0

still doing the same thing. Not giving points or saying already entered code.

0

could i just use tick()??

0

Output?

0

LocalScripts cannot use LoadBoolean..

0

If I made it serverscript then I couldnt use LocalPlayer for the top variable

0

...You never said it was a LocalScript. Don't use LoadBoolean. Use something like script.Parent.Parent.Parent.Parent.Parent. Basically, Thr script is something like this.... Player>PlayerGui>ScreenGui>Button>LocalScript. Make it not Local, and just use script.Parent.Parent.Parent... until you get the Player. Sorry, forgot about that. :c I'm pathetic...

0

its ok, im sorry, I just thought since it had LocalPlayer it meant LocalScript

0

I have put in a normalscript and done the script.Parent, etc to get to player, but it dosent work at all now. I have editted

0

...I have no idea what's happening to it. What's the Output? What do you mean "it doesnt work at all", and how did you edit it?

0

i just changed it to a normal script inside the textbutton and i change the player, i eddited my answer with it. Is there any actual way to get this working?

0

If you do it right it works. :p

0

i did do it right

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