#swordfighting game script wont work

89 messages · Page 1 of 1 (latest)

knotty jolt
#

the intermission is stuck on 5 seconds and doesnt change to game time when the game start

local countdown
local TextLabel = game.StarterGui.ScreenGui.TextLabel
local intermissionTime = 5
local gameTime = 15

while true do 
    gameon = false 
    for i = intermissionTime, 0, -1 do
        TextLabel.Text = ("Intermission: ".. i)
        wait(1)
    end
    TextLabel.Text = ("Intermission: 0")
    for i, player in pairs (game.Players:GetPlayers()) do 
        player.Character:MoveTo(Vector3.new(87, 23, 57))
        local giveSword = game.ReplicatedStorage.ClassicSword:Clone()
        giveSword.Parent = player:FindFirstChild("Backpack") 
    end
    gameon = true
    for i = gameTime, 0, -1 do
        TextLabel.Text = ("Game Time: ".. i)
        wait(1)
    end
    TextLabel.Text = ("Game Time: 0")
    for i, player in pairs (game.Players:GetPlayers()) do 
        player.Character:MoveTo(Vector3.new(91, 6, 16)) 
        player:FindFirstChild("Backpack"):ClearAllChildren()
    end
end```
warm swift
#

I dont understand what you want

timid runeBOT
#

studio** You are now Level 2! **studio

warm swift
#

Do you want to make intermission time go once in a server? or each round

#

@knotty jolt

knotty jolt
#

what

#

ioh

#

each round

#

the while true do thing should make it do that right

warm swift
#

yea

#

so is only going 5 seconds?

#

instead of 15?

knotty jolt
#

hm?

#

the intermission should be 5, the game should be 15

#

ive updated the script a little bit but its still not working

#

heres the updated version

#
local countdown
local TextLabel = game.StarterGui.ScreenGui.TextLabel
local intermissionTime = 5
local gameTime = 15

function updateText(newText)
    game:WaitForChild("StarterGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel").Text = newText
end

while true do  
    for i = intermissionTime, 0, -1 do
        updateText("Intermission: " .. i)
        wait(1)
    end
    for i, player in pairs (game.Players:GetPlayers()) do 
        player.Character:MoveTo(Vector3.new(87, 23, 57))
        local giveSword = game.ReplicatedStorage.ClassicSword:Clone()
        giveSword.Parent = player:FindFirstChild("Backpack") 
    end
    for i = gameTime, 0, -1 do
        updateText("Game Time: " .. i)
        wait(1)
    end
    for i, player in pairs (game.Players:GetPlayers()) do 
        player.Character:MoveTo(Vector3.new(91, 6, 16)) 
        player:FindFirstChild("Backpack"):ClearAllChildren()
    end
end```
warm swift
#

whats the problem?

#

i dont understand the script looks good

#

@knotty jolt

knotty jolt
#

yeah idfk

#

the timer

#

doesnt update at all

#

and stays on "Intermission: 5"

#

even when the game starts

warm swift
#

the text?

knotty jolt
#

yeah the text

#

i mean that lol

warm swift
#

oh ok

#

where is this script

#

like in the explorer

knotty jolt
#

yeah its in serverscriptservice

#

but ive tried it in workplace

warm swift
#

there is the problem

knotty jolt
#

?

warm swift
#

Workplace and serverscriptservice only take server scripts

#

put it in starterGui

#

or

knotty jolt
#

am i supposed to put this thing in a localscript?

#

....

#

LMAO

warm swift
#

StarterPlayerScripts

knotty jolt
#

it is a serverscript

#

but ill change it over to a localscript

warm swift
#

wait hold on...

knotty jolt
#

honestly i still dont know much of a difference

#

.?

warm swift
knotty jolt
#

yeah

#

i just created a local verison to test it

#

why?

warm swift
#

so

#
local TextLabel = game.StarterGui.ScreenGui.TextLabel```
#

This is editing the servers version

#

not player version

knotty jolt
#

switched it over to a local script and put it in starterplayerscripts but now the text wont change at all

warm swift
#

ok

#
local countdown

local intermissionTime = 5
local gameTime = 15

function updateText(newText)
    for i,v in pairs(game.Players:GetPlayers()) do
        v:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel").Text = newText
    end
end

while true do  
    for i = intermissionTime, 0, -1 do
        updateText("Intermission: " .. i)
        wait(1)
    end
    for i, player in pairs (game.Players:GetPlayers()) do 
        player.Character:MoveTo(Vector3.new(87, 23, 57))
        local giveSword = game.ReplicatedStorage.ClassicSword:Clone()
        giveSword.Parent = player:FindFirstChild("Backpack") 
    end
    for i = gameTime, 0, -1 do
        updateText("Game Time: " .. i)
        wait(1)
    end
    for i, player in pairs (game.Players:GetPlayers()) do 
        player.Character:MoveTo(Vector3.new(91, 6, 16)) 
        player:FindFirstChild("Backpack"):ClearAllChildren()
    end
end```
#

Try this script in a serverscript

knotty jolt
#

whats changed?

warm swift
#

inside serverscriptservice

knotty jolt
#

im a beginner and i want to atleast learn

warm swift
#
function updateText(newText)
    for i,v in pairs(game.Players:GetPlayers()) do
        v:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel").Text = newText
    end
end```
#

Now its looping every player in the game

#

and changeing the values

knotty jolt
#

ohhhh

warm swift
#

Put that script in a Server Script. Which is inside Server Script Service

#

Should be fixed

knotty jolt
#

woahh

#

nothing changed..

#

but now its stuck on "Intermission: 4"

#

i guess thats a start

warm swift
#

hm

#

alr wait let me get on studio

knotty jolt
#

did i get anything wrong here

local TextLabel = game.StarterGui.ScreenGui.TextLabel
local intermissionTime = 5
local gameTime = 15

function updateText(newText)
    for i,v in pairs (game.Players:GetPlayers()) do
        game:WaitForChild("StarterGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel").Text = newText
    end
end

while true do  
    for i = intermissionTime, 0, -1 do
        updateText("Intermission: " .. i)
        wait(1)
    end
    for i, player in pairs (game.Players:GetPlayers()) do 
        player.Character:MoveTo(Vector3.new(87, 23, 57))
        local giveSword = game.ReplicatedStorage.ClassicSword:Clone()
        giveSword.Parent = player:FindFirstChild("Backpack") 
    end
    for i = gameTime, 0, -1 do
        updateText("Game Time: " .. i)
        wait(1)
    end
    for i, player in pairs (game.Players:GetPlayers()) do 
        player.Character:MoveTo(Vector3.new(91, 6, 16)) 
        player:FindFirstChild("Backpack"):ClearAllChildren()
    end
end```
#

i gotta go for a bit

knotty jolt
#

damn it worked

#

how

#

whats different

warm swift
#
game:WaitForChild("StarterGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel").Text = newText```
#

game:WaitForChild("StarterGui") Is supposed to be v:WaitForChild("PlayerGui")

knotty jolt
#

ohhhh

#

alright cool

#

thanks

#

ive been at this script all day

warm swift
timid runeBOT
#

studio** You are now Level 3! **studio