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

A twitter GUI works even after a player resets, and doesnt even WORK right now?

Asked by
Vid_eo 126
8 years ago
shared.TwitterStatus = nil -- this is a shared Variable that can be accessed from any script in the game, It is currenty set to nil until we use it to prevent bugs

local gear = game.ReplicatedStorage:WaitForChild("GravityCoil")
    game.Players.PlayerAdded:connect(function(plr) 
        shared.TwitterStatus = false -- now that we are using it, it is no longer nil and has a value.
    --It is also setting the variable once when the player is added to prevent it from being added again when player respawns
            script.Parent.MouseButton1Click:connect(function()
             if script.Parent.Parent.Input.Text == 'Alpha!' and shared.TwitterStatus == false then
                 shared.TwitterStatus = true -- now that it is true, it cannot be ran in this condition again. But as i said before, it can be edited from any script, so u can change it later
                 gear:Clone().Parent = game.Players.LocalPlayer.Backpack
            script.Parent.Parent.Input.Text = ''
                 script.Parent.Text = 'Success!'
        wait(1)
                 script.Parent.Text = 'Submit'
    else
                 script.Parent.Parent.Input.Text = 'Submit'
                    script.Parent.Text = 'Invalid Code'
        wait(1)
                    script.Parent.Text = 'Submit'
    end

    end)
end)
1
Clone into the players starterpack FiredDusk 1466 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Bleh. Putting something in Backpack is temporary, the item gets removed when you die/leave the game.

But if you want to do it manually:

local debounce = false

if debounce == false and script.Parent.Parent.Input.Text == 'Alpha!' then
    debounce = true
    -- code
end

EDIT:

This is a script inside a twitter code gui. Hierarchy:

  • StarterGui
    • TwitterGui
      • TextButton (name 'button')
      • TextBox (named 'input')
      • LocalScript

Script:

local item = game.ReplicatedStorage:WaitForChild("ItemName")
local debounce  = false
local button = script.Parent.Button
local input = script.Parent.Input
local code = "code"
local starterText = "Enter Twitter code here"

button.MouseButton1Down:connect(function()
    if debounce == false and input.Text == code then
        debounce = true
        local clone = item:Clone()
        clone.Parent = game.Players.LocalPlayer.Backpack
    elseif input.Text ~= code then
        input.Text = "Invalid Code"
    elseif debounce == true then
        input.Text = "Already entered code for this life"
    end
end)
0
Yes, but once they die, they could re - enter the code. Vid_eo 126 — 8y
0
Yes, this does that. TheDeadlyPanther 2460 — 8y
Ad

Answer this question