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

Problem with my fighting script? (Gui)

Asked by
Relatch 550 Moderation Voter
9 years ago

The gui doesn't show any text in-game or in test solo. Also, there are no errors.

Award = 1
local gui = game.StarterGui.Control.Text

game.Players.PlayerAdded:connect(function(plr)
    local leaderstats = Instance.new("IntValue")
    leaderstats.Name = "leaderstats"

    local points = Instance.new("IntValue")
    points.Name = "Points"

    points.Parent = leaderstats
    leaderstats.Parent = plr
end)

GIP = false
function Fight()
    winner = "no one"
    ended = false
    GIP = true
    for i = 15, 0, -1 do
        if i <= 9 then
            gui.Text = "Intermission (0:0"..i..")"
        else
            gui.Text = "Intermission (0:"..i..")"
        end
        wait(1)
    end
    gui.Text = "Now choosing duelers."
    wait(5)

    local plrs = game.Players:GetPlayers()
    if #plrs <= 2 then
    local p1 = plrs [math.random(1, #plrs)]
    local p2 = plrs [math.random(1, #plrs)]
    ended = false
    repeat p2 = plrs[math.random(1, #plrs)] until p2 ~= p1

    gui.Text = p1.Name.. " and " ..p2.Name.. " have been chosen to duel."
    wait(3)

    p1.Character.Torso.CFrame = CFrame.new(148.9, 13.6, 14.4) 
    p2.Character.Torso.CFrame = CFrame.new(148.9, 13.6, -59.6)

    local sword1 = game.ServerStorage.Sword1:Clone()
    sword1.Parent = p1.Backpack

    local sword2 = game.ServerStorage.Sword2:Clone()
    sword2.Parent = p2.Backpack

    wait(2)

    p1.Character.Humanoid.WalkSpeed = 0
    p2.Character.Humanoid.WalkSpeed = 0

    for i = 3, 0, -1 do
        gui.Text = "Starting in (0:0"..i..")"
        wait(1)
        if p1.Character ~= nil and p2.Character ~= nil then
        else ended = true break 
        end
    end

    p1.Character.Humanoid.WalkSpeed = 16
    p2.Character.Humanoid.WalkSpeed = 16

    wait(0.1)

    for i = 30, 0, -1 do
        if ended == true then break end
        gui.Text = "Round, please wait (0:"..i..")"
        if i <= 9 then
            gui.Text = "Round, please wait (0:0"..i..")"
        end
        game.Players.PlayerRemoving:connect(function(player)
            if player.Name == p1.Name then winner = p2.Name ended = true end
        end)
        game.Players.PlayerRemoving:connect(function(player)
            if player.Name == p1.Name then winner = p2.Name ended = true end
        end)
        if p1.Character ~= nil then p1.Character.Humanoid.Died:connect(function()
            if ended == false then
            p2.leaderstats.Points.Value = p2.leaderstats.Points.Value + Award
            winner = p2.Name
            --game:GetService("PointsService"):AwardPoints(p2.userId,1)
            ended = true end
        end)end
        if p2.Character~=nil then p2.Character.Humanoid.Died:connect(function()if ended == false then
            p1.leaderstats.Points.Value = p1.leaderstats.Points.Value + Award
            winner = p1.Name
            --game:GetService("PointsService"):AwardPoints(p1.userId,1)
            ended = true end
        end)end wait(1)
        if ended == true then wait()break end
    end
    if p1.Character ~= nil then
    p1.Character.Torso.CFrame = CFrame.new(192.9, 3.4, -30.1) 
    while wait() do if p1.Character.Humanoid ~= nil then p1.Character.Humanoid:UnequipTools() break end end
    p1.Backpack:ClearAllChildren()end

    if p2.Character ~= nil then p2.Character.Torso.CFrame = CFrame.new(183.9, 3.4, -30.1)
    p2.Character.Humanoid:UnequipTools()
    p2.Backpack:ClearAllChildren() end end
    gui.Text = winner.." has won"
    wait(2)
    GIP = false
end

while true do
    if game.Players.NumPlayers > 1 and GIP == false then
        wait(0.5)
        Fight()
    elseif game.Players.NumPlayers == 1 then
        gui.Text = "Waiting for 2 or more players."
    end
    wait()
end
0
It seems you are doing this incorrectly, I will try to explain it and all. YasuYoshida 171 — 9y
0
The whole entire thing!? Relatch 550 — 9y
0
No, I only looked at the text part of the script. I don't know if there is anything else wrong with your script. YasuYoshida 171 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

So I noticed that you were trying to change the Text in StarterGui, but this will not work due to the fact that it's changing the gui in StartGui. You must change the text in the player. I have made a function that should change the text for all players. If this does not work then I don't know what is. If you want to change the text for all players then use the example below.

ChangeText("This will Edit the Text")

I hope this works for you.

Award = 1

game.Players.PlayerAdded:connect(function(plr)
    local leaderstats = Instance.new("IntValue")
    leaderstats.Name = "leaderstats"

    local points = Instance.new("IntValue")
    points.Name = "Points"

    points.Parent = leaderstats
    leaderstats.Parent = plr
end)

function ChangeText(Text)
    for _,v in pairs(game.Players:GetChildren()) do
        local StarterGui = v.StarterGui
        if StarterGui:FindFirstChild("Control") then
            StarterGui:FindFirstChild("Control")["Text"].Text = Text
        end
    end
end

GIP = false
function Fight()
    winner = "no one"
    ended = false
    GIP = true
    for i = 15, 0, -1 do
        if i <= 9 then
            ChangeText("Intermission (0:0"..i)
        else
            ChangeText("Intermission (0:"..i..")")
        end
        wait(1)
    end
    ChangeText("Now choosing duelers.")
    wait(5)

    local plrs = game.Players:GetPlayers()
    if #plrs <= 2 then
    local p1 = plrs [math.random(1, #plrs)]
    local p2 = plrs [math.random(1, #plrs)]
    ended = false
    repeat p2 = plrs[math.random(1, #plrs)] until p2 ~= p1

   ChangeText(p1.Name.. " and " ..p2.Name.. " have been chosen to duel.")
    wait(3)

    p1.Character.Torso.CFrame = CFrame.new(148.9, 13.6, 14.4) 
    p2.Character.Torso.CFrame = CFrame.new(148.9, 13.6, -59.6)

    local sword1 = game.ServerStorage.Sword1:Clone()
    sword1.Parent = p1.Backpack

    local sword2 = game.ServerStorage.Sword2:Clone()
    sword2.Parent = p2.Backpack

    wait(2)

    p1.Character.Humanoid.WalkSpeed = 0
    p2.Character.Humanoid.WalkSpeed = 0

    for i = 3, 0, -1 do
        ChangeText("Starting in (0:0"..i..")")
        wait(1)
        if p1.Character ~= nil and p2.Character ~= nil then
        else ended = true break 
        end
    end

    p1.Character.Humanoid.WalkSpeed = 16
    p2.Character.Humanoid.WalkSpeed = 16

    wait(0.1)

    for i = 30, 0, -1 do
        if ended == true then break end
        ChangeText("Round, please wait (0:"..i..")")
        if i <= 9 then
            ChangeText("Round, please wait (0:0"..i..")")
        end
        game.Players.PlayerRemoving:connect(function(player)
            if player.Name == p1.Name then winner = p2.Name ended = true end
        end)
        game.Players.PlayerRemoving:connect(function(player)
            if player.Name == p1.Name then winner = p2.Name ended = true end
        end)
        if p1.Character ~= nil then p1.Character.Humanoid.Died:connect(function()
            if ended == false then
            p2.leaderstats.Points.Value = p2.leaderstats.Points.Value + Award
            winner = p2.Name
            --game:GetService("PointsService"):AwardPoints(p2.userId,1)
            ended = true end
        end)end
        if p2.Character~=nil then p2.Character.Humanoid.Died:connect(function()if ended == false then
            p1.leaderstats.Points.Value = p1.leaderstats.Points.Value + Award
            winner = p1.Name
            --game:GetService("PointsService"):AwardPoints(p1.userId,1)
            ended = true end
        end)end wait(1)
        if ended == true then wait()break end
    end
    if p1.Character ~= nil then
    p1.Character.Torso.CFrame = CFrame.new(192.9, 3.4, -30.1) 
    while wait() do if p1.Character.Humanoid ~= nil then p1.Character.Humanoid:UnequipTools() break end end
    p1.Backpack:ClearAllChildren()end

    if p2.Character ~= nil then p2.Character.Torso.CFrame = CFrame.new(183.9, 3.4, -30.1)
    p2.Character.Humanoid:UnequipTools()
    p2.Backpack:ClearAllChildren() end end
    ChangeText(winner.." has won")
    wait(2)
    GIP = false
end

while true do
    if game.Players.NumPlayers > 1 and GIP == false then
        wait(0.5)
        Fight()
    elseif game.Players.NumPlayers == 1 then
        ChangeText("Waiting for 2 or more players.")
    end
    wait()
end
Ad

Answer this question