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

Twitter Redeem Code How-To, left script I made?

Asked by
Jxemes 75
6 years ago

I'm currently making a script for redeeming codes to get a knife or cash. I'm trying to execute it by testing with knife first (if I can correctly do knife, I can do cash) But when I type in the code, It won't work. Anyone got tips of how to fix this?


local player = game.Players.LocalPlayer local shop = player.PlayerGui.ShopGUI.ShopMaster local codepage = shop.Pages.Codes local codebox = codepage.CodeFrame.Code function onActivated() if codebox.Text == "Code1" then game.ReplicatedStorage.Knives.CodeKnife:clone().Parent = player.Backpack end end codebox.Changed:connect(function(onActivated)

BTW, can I also change "onActivated" to something else that is not global?

1 answer

Log in to vote
1
Answered by 6 years ago

An simple fix is you add a Button called Submit or Enter so that every time it is clicked, it checks the text and if the text is correct then it gives the player whatever the code gives, for example;

This is the positions;

--------------StarterGui -----------ScreenGui ---------TextBox ---------SubmitButton(TextButton) -------LocalScript

This means StarterGui is the main parent, then screen Gui and inside of ScreenGui you have a TextBox and a button and inside of button you have the local script which is the controller,

Now code;

local Plr = game.Players.LocalPlayer
local shop = script.Parent.Parent.Parent:WaitForChild('ShopGUI').ShopMaster -- This line may have to be changed
local SB = script.Parent -- SubmitButton
local CB = SB.Parent:WaitForChild('TextBox') -- change the name to whatever you named your textbox
local Code = 'Code1' -- change this to your code
local CodeKnife = game.ReplicatedStorage.Knives:WaitForChild('CodeKnife')

SB.MouseButton1Down:Connect(function() -- functions on click
    if CB.Text == Code then
        CodeKnife:Clone()
        CodeKnife.Parent = Plr.Backpack
    end
end)

Make sure you have all Gui Objects and change what is necessary. If you followed along and did everything then it should work, if it doesn't work comment the error or fix it if you can.

:WaitForChild() waits for the child to load in so that it would work in both studio and game.

If this helped then please accept answer ;)

Good luck and have fun developing!

0
Works well! Thanks! Jxemes 75 — 6y
0
No problem BlackOrange3343 2676 — 6y
Ad

Answer this question