So I have this srippt, and you enter a code into a text box and your supposed to get leaderstats from it and it doesnt work and i dont know why please somebody help this is quite urgent thank merry xmas
local box = script.Parent local plr = game.Players.LocalPlayer local redeemed = false box.FocusLost:connect(function(click) if box.Text == "Test" and redeemed == false then local player = game.Players:GetPlayerByUserId(click.PlayerId) player.leaderstats.Bills.Value = player.leaderstats.Bills.Value + 70 redeemed = true box.Text = "Code Accepted!" wait(1) box.Text = "Redeem Code" elseif box.Text == "Test" and redeemed == true then box.Text = "Already Used!" wait(1) box.Text = "Redeem Code" else box.Text = "Code Declined!" wait(1) box.Text = "Redeem Code" end end)
why does this have 3 upvotes, i didnt even send an explanation wow
local box = script.Parent local plr = game.Players.LocalPlayer local redeemed = false box.FocusLost:connect(function() if box.Text == "Test" and redeemed == false then local player = game.Players:GetPlayerByUserId(plr.UserId) player.leaderstats.Bills.Value = player.leaderstats.Bills.Value + 70 redeemed = true box.Text = "Code Accepted!" wait(1) box.Text = "Redeem Code" elseif box.Text == "Test" and redeemed == true then box.Text = "Already Used!" wait(1) box.Text = "Redeem Code" else box.Text = "Code Declined!" wait(1) box.Text = "Redeem Code" end end)
Do not do this by the client. That's how you get your game exploited and how people develop infinite cash exploits.
Local script:
local box = script.Parent local plr = game.Players.LocalPlayer local redeemed = false box.FocusLost:connect(function(click) local result = game.ReplicatedStorage.TwitterCode:InvokeServer(box.Text) if result == "valid & entered" then -- from here you can add the rest of your code system if you like redeemed = true box.Text = "Code Accepted!" wait(1) box.Text = "Redeem Code" else -- sample end end
Create a remote function, put it in replicated Storage and title it accordingly.
Then add a server script to ServerScriptService:
game.ReplicatedStorage.TwitterCode.OnServerInvoke = function(plr, code) if code == "Test" then -- doing an extra check for no reason but why not game.Players[plr.Name].leaderstats.Bills.Value = game.Players[plr.Name].leaderstats.Bills.Value + 70 return "valid & entered" end end