Items not going into the invintory

I would like a random tool that you get when the game starts.


Script inside of text label

text = script.Parent.TextLabel

function Intermition()
local Lobby = game.Workspace.Lobby
print("Intermition")
for i = 10, 0, -1 do
		text.Text = "INTERMISION ".. i
		wait(1)
		print("i = "..i)
	end
	for o = 10, 0, -1 do
		text.Text = "GAME STARTING IN " .. o
		Lobby.Parent = game.ReplicatedStorage
		wait(1)
	end
	Lobby.Parent = game.Workspace
	local wepon = math.random(1, 4)
	if wepon == 1 then-----------------------------------Not working
		game.ReplicatedStorage.ToolEvents.GunEvent:FireServer()
		Start()		
	end
	if wepon == 2 then
		game.ReplicatedStorage.ToolEvents.SlingShotEvent:FireServer()
		Start()		
	end
	if wepon == 3 then
		game.ReplicatedStorage.ToolEvents.KnifeEvent:FireServer()
		Start()		
	end
	if wepon == 4 then
		game.ReplicatedStorage.ToolEvents.Sword:FireServer()---Up to here

		Start()		
	end
end
function Start()
	print("Start")
	for n = 60, 0, -1 do
		text.Text = "TIME LEFT ".. n
	wait(1)
	print("n = "..n)
		if n == 0 then
			Intermition()
		end
	end
end

Intermition()

This is a script is serverscriptservice

while true do
game.ReplicatedStorage.ToolEvents.GunEvent.OnServerEvent:Connect(function(player)
	game.ServerStorage.Tools.Handgun.clone().parent = player.Backpack
end)
game.ReplicatedStorage.ToolEvents.SlingShotEvent.OnServerEvent:Connect(function(player)
	game.ServerStorage.Tools.ClassicSlingshot.clone().parent = player.Backpack
end)
game.ReplicatedStorage.ToolEvents.Sword.OnServerEvent:Connect(function(player)
	game.ServerStorage.Tools.ClassicSword.clone().parent = player.Backpack
end)
game.ReplicatedStorage.ToolEvents.KnifeEvent.OnServerEvent:Connect(function(player)
	game.ServerStorage.Tools.Blade.clone().parent = player.Backpack
	end)
end


Thak you for reading this :slight_smile:

There are a lot of problems I see in this. You shouldn’t use a while true do to connect OnServerEvents. You also shouldn’t be firing an event for this (even though it’s not working because it is a server script). Also, you need to define events before calling them. Here is what you should do.

Have a local script within the text label for handling text, and a server script inside of server script service to handle the game. You will also need a number value within ReplicatedStorage called “Time,” and a bool value called “Started.”

LocalScript:

local text = script.Parent.TextLabel

local Time = game.ReplicatedStorage.Time
local Started = game.ReplicatedStorage.Started

local lastvalue
local starting = false

Time:GetPropertyChangedSignal("Value"):Connect(function()
    if Started.Value then
        started = false
        text.Text = "TIME LEFT "..Time.Value
    else
        text.Text = "INTERMISION "..Time.Value
        
        if lastvalue and lastvalue == 0 then
            starting = true
        end
        
        if starting then
            text.Text = "GAME STARTING IN "..Time.Value
        end
    end

    lastvalue = Time.Value
end)

Server Script in ServerScriptService:

local Time = game.ReplicatedStorage.Time
local Started = game.ReplicatedStorage.Started

Time.Value = 20

while task.wait(1) do
    Time.Value -= 1
    
    if Time.Value == 0 then
        if not Started.Value then
            Time.Value = 10
            repeat
                Time.Value -= 1
                task.wait()
            until Time.Value == 0
            Started.Value = true
            Time.Value = 60
        else
            Time.Value = 10
            Started.Value = false
        end
    end
end