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

How to check if previously entered?

Asked by 10 years ago
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

Log in to vote
1
Answered by
Kratos232 105
10 years ago

...

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
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? NinjoOnline 1146 — 10y
0
Thanks for all the ways. I can rate up, but cant accept till i actually test which wont be till tomorrow NinjoOnline 1146 — 10y
0
I guess you could, or you could make a time system using tick(), but I guess that'd be weird. :P Kratos232 105 — 10y
0
I have editted my question with what I am trying to test, please look at it NinjoOnline 1146 — 10y
View all comments (14 more)
0
I had to edit my answer, sorry. I think it should work with that. Kratos232 105 — 10y
0
My code isnt gonna be 12345 :p just for testing purposes NinjoOnline 1146 — 10y
0
still doing the same thing. Not giving points or saying already entered code. NinjoOnline 1146 — 10y
0
could i just use tick()?? NinjoOnline 1146 — 10y
0
Output? Kratos232 105 — 10y
0
LocalScripts cannot use LoadBoolean.. NinjoOnline 1146 — 10y
0
If I made it serverscript then I couldnt use LocalPlayer for the top variable NinjoOnline 1146 — 10y
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... Kratos232 105 — 10y
0
its ok, im sorry, I just thought since it had LocalPlayer it meant LocalScript NinjoOnline 1146 — 10y
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 NinjoOnline 1146 — 10y
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? Kratos232 105 — 10y
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? NinjoOnline 1146 — 10y
0
If you do it right it works. :p Kratos232 105 — 10y
0
i did do it right NinjoOnline 1146 — 10y
Ad

Answer this question