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

How should I let the script be able to reveal a value's value?

Asked by 3 years ago

So I'm making a trading system for Evercyan's RPG Kit and I noticed a problem. My script wasn't detecting a value's value. Here is the script:

local player1 = script.Parent.Parent.Parent.Parent
local playername = player1.TradePlayer
local player2 = game.Players:WaitForChild(playername.Value)
local readyon = false
local confirmon = false
while true do
    wait()
    if script.Parent.Visible == true then
    if readyon == false then
        if player1.PlayerGui.NotifGUI.Trading.Ready.Text == "Ready" and player2.PlayerGui.NotifGUI.Trading.Ready.Text == "Ready" then
            readyon = true
            player1.PlayerGui.NotifGUI.Trading.Ready.Text = "Confirm"
            player2.PlayerGui.NotifGUI.Trading.Ready.Text = "Confirm"
            confirmon = true
        end
    end
    if confirmon == true then
        if player1.PlayerGui.NotifGUI.Trading.Ready.Visible == false and player2.PlayerGui.NotifGUI.Trading.Ready.Visible == false then
            confirmon = false
            readyon = false
            local gui1 = script.Parent
            local gui2 = player2.PlayerGui.NotifGUI.Trading
            local sword1 = gui1.SwordA
            local sword2 = gui1.SwordB
            local sword3 = gui1.SwordC
            local sword4 = gui1.SwordD
            local sword5 = gui1.SwordE
            local othersword1 = gui2.SwordA
            local othersword2 = gui2.SwordB
            local othersword3 = gui2.SwordC
            local othersword4 = gui2.SwordD
            local othersword5 = gui2.SwordE
            if not sword1.Text == "Empty Slot" then
                player1.StarterGear:WaitForChild(sword1.Text):Destroy()
            end
            if not sword2.Text == "Empty Slot" then
                player1.StarterGear:WaitForChild(sword2.Text):Destroy()
            end
            if not sword3.Text == "Empty Slot" then
                player1.StarterGear:WaitForChild(sword3.Text):Destroy()
            end
            if not sword4.Text == "Empty Slot" then
                player1.StarterGear:WaitForChild(sword4.Text):Destroy()
            end
            if not sword5.Text == "Empty Slot" then
                player1.StarterGear:WaitForChild(sword5.Text):Destroy()
            end
            if not othersword1.Text == "Empty Slot" then
                local tool = game.ReplicatedStorage.GameItems:WaitForChild(othersword1.Text):Clone()
                tool.Parent = player1.StarterGear
            end
            if not othersword2.Text == "Empty Slot" then
                local tool = game.ReplicatedStorage.GameItems:WaitForChild(othersword2.Text):Clone()
                tool.Parent = player1.StarterGear
            end
            if not othersword3.Text == "Empty Slot" then
                local tool = game.ReplicatedStorage.GameItems:WaitForChild(othersword3.Text):Clone()
                tool.Parent = player1.StarterGear
            end
            if not othersword4.Text == "Empty Slot" then
                local tool = game.ReplicatedStorage.GameItems:WaitForChild(othersword4.Text):Clone()
                tool.Parent = player1.StarterGear
            end
            if not othersword5.Text == "Empty Slot" then
                local tool = game.ReplicatedStorage.GameItems:WaitForChild(othersword5.Text):Clone()
                tool.Parent = player1.StarterGear
                end
                player1:LoadCharacter()
                player2:LoadCharacter()
        end
        end
    end
end
0
what value? tell me the line too. btw use "local player1 = game.Players.LocalPlayer" instead of that messy one (bad practice) acediamondn123 147 — 3y
0
It's not a local script and playername is the value. For some reason when it does have a value and I print it's value it says it's "" for no reason at all. CandyWreckEpicness 115 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I realized my mistake. You have to put it after the if visible thing.

local readyon = false
local confirmon = false
while true do
    wait()
    if script.Parent.Visible == true then
        local player1 = script.Parent.Parent.Parent.Parent
        local playername = script.Parent.Parent.Parent.Parent.TradePlayer.Value
        local player2 = game.Players:WaitForChild(playername)
        if readyon == false then
            if player1.PlayerGui.NotifGUI.Trading.Ready.Text == "Ready" and player2.PlayerGui.NotifGUI.Trading.Ready.Text == "Ready" then
                readyon = true
                player1.PlayerGui.NotifGUI.Trading.Ready.Text = "Confirm"
                player2.PlayerGui.NotifGUI.Trading.Ready.Text = "Confirm"
                confirmon = true
            end
        end
        if confirmon == true then
            if player1.PlayerGui.NotifGUI.Trading.Ready.Visible == false and player2.PlayerGui.NotifGUI.Trading.Ready.Visible == false then
                confirmon = false
                readyon = false
                local gui1 = script.Parent
                local gui2 = player2.PlayerGui.NotifGUI.Trading
                local sword1 = gui1.SwordA
                local sword2 = gui1.SwordB
                local sword3 = gui1.SwordC
                local sword4 = gui1.SwordD
                local sword5 = gui1.SwordE
                local othersword1 = gui2.SwordA
                local othersword2 = gui2.SwordB
                local othersword3 = gui2.SwordC
                local othersword4 = gui2.SwordD
                local othersword5 = gui2.SwordE
                if not sword1.Text == "Empty Slot" then
                    player1.StarterGear:WaitForChild(sword1.Text):Destroy()
                end
                if not sword2.Text == "Empty Slot" then
                    player1.StarterGear:WaitForChild(sword2.Text):Destroy()
                end
                if not sword3.Text == "Empty Slot" then
                    player1.StarterGear:WaitForChild(sword3.Text):Destroy()
                end
                if not sword4.Text == "Empty Slot" then
                    player1.StarterGear:WaitForChild(sword4.Text):Destroy()
                end
                if not sword5.Text == "Empty Slot" then
                    player1.StarterGear:WaitForChild(sword5.Text):Destroy()
                end
                if not othersword1.Text == "Empty Slot" then
                    local tool = game.ReplicatedStorage.GameItems:WaitForChild(othersword1.Text):Clone()
                    tool.Parent = player1.StarterGear
                end
                if not othersword2.Text == "Empty Slot" then
                    local tool = game.ReplicatedStorage.GameItems:WaitForChild(othersword2.Text):Clone()
                    tool.Parent = player1.StarterGear
                end
                if not othersword3.Text == "Empty Slot" then
                    local tool = game.ReplicatedStorage.GameItems:WaitForChild(othersword3.Text):Clone()
                    tool.Parent = player1.StarterGear
                end
                if not othersword4.Text == "Empty Slot" then
                    local tool = game.ReplicatedStorage.GameItems:WaitForChild(othersword4.Text):Clone()
                    tool.Parent = player1.StarterGear
                end
                if not othersword5.Text == "Empty Slot" then
                    local tool = game.ReplicatedStorage.GameItems:WaitForChild(othersword5.Text):Clone()
                    tool.Parent = player1.StarterGear
                end
                sword1.Parent.Visible = false
                player1:LoadCharacter()
            end
        end
    end
end
Ad

Answer this question