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

Twitter Code Reedem?

I'm trying to make a code that will give 50 walkspeed and 200 + life but its not work


local box = script.Parent.Parent.TextBox
local plr = script.Parent.Parent.Parent.Parent
function onClick()
	
	if box.Text == "1337" then
	box.Text = "Code Redeemed!"
	wait(2)
	box.Text = "Special Code"
	local b = game.Players.Humanoid.WalkSpeed = 50 
	else
	box.Text = "Wrong Code!"
	wait(2)	
	box.Text = "Special Code"
		
		
	end
end
	script.Parent.MouseButton1Click:connect(onClick)

Line 9 got an error, but i can't see it Please Help Me ASAP

1 comment

0

If you want further advancement in Twitter Codes, go here: http://wiki.roblox.com/index.php?title=Data_store

5 answers

Here you added the walkspeed as a Variable and you don't want to do that. I rewrote it a bit:

local plr=game.Players.LocalPlayer
local chr=plr.Character

box=script.Parent.TEXT
code=script.Parent.CODE
function clicked()
	if box.Text=="1337" then
		box.Text="Correct!"
		wait(2)
		box.Text="Code"
		chr.Humanoid.WalkSpeed=50
	else
		box.Text="nope"
		wait(2)
		box.Text="Code"
	end
end

code.MouseButton1Down:connect(clicked)

You can change the name of the Variables.

1 comment

0

Why did this get downvoted :P

You need to check if a code was entered, so you need to change your function. Also, you used "=" twice on line 9, so you need to get rid of your "local b" and change game.Players to just plr since you explained what it was. You also need to check if the code was redeemed or not already, which you would wanna set a value to check.

local box = script.Parent.Parent.TextBox
local plr = script.Parent.Parent.Parent.Parent
local redeemed = false

box.FocusLost:connect(function()
	if box.Text == "1337" and redeemed == false then
		redeemed = true
	    box.Text = "Code Accepted!"
		plr.Chracter.Humanoid.WalkSpeedSpeed = 50
	    wait(1)
	    box.Text = "Redeem Code"
	elseif box.Text == "1337" 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)

It is not referencing the player! Here is a fixed script.

local box = script.Parent.Parent.TextBox
local player = game.Players.LocalPlayer
function onClick()

    if box.Text == "1337" then
    box.Text = "Code Redeemed!"
    wait(2)
    box.Text = "Special Code"
    player.Humanoid.WalkSpeed = 50 
    else
    box.Text = "Wrong Code!"
    wait(2) 
    box.Text = "Special Code"


    end
end
    script.Parent.MouseButton1Click:connect(onClick)

On line nine, you have two equal signs in different locations. Lua syntax does not permit this, remove 'local b ='.

3 comments

0

i'll try now

0

its not giving me the walkspeed

0

Why exactly was this downvoted twice?

local box = script.Parent.Parent.TextBox
local plr = script.Parent.Parent.Parent.Parent
function onClick()

    if box.Text == "1337" then
    box.Text = "Code Redeemed!"
    wait(2)
    box.Text = "Special Code"
    plr.Character.Humanoid.WalkSpeed = 50
    else
    box.Text = "Wrong Code!"
    wait(2) 
    box.Text = "Special Code"


    end
end
    script.Parent.MouseButton1Click:connect(onClick)

4 comments

1

Please provide information with your code and what you did to fix the code, otherwise the Asker may not benefit if they have no idea what was changed.,

1

Please add a Desc. Show the user's Mistakes. Show your changes.

0

what did it changed from mine?

0

i CAN'T add other codes??

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