I need help with items giving to player when the round starts

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? giving item to player when player joins

  2. What is the issue? code not working

–And no errors in the Output

local gamestring = game.ReplicatedStorage.GameString
local cantp = game.ReplicatedStorage.cantp
local gear = game.ServerStorage.Wacker

cantp.Changed:Connect(function()--when the boolean is changed then do
if cantp.Value == true then--if true then/always add .Value for boolean or intvalue
		for _,player in pairs(game.Players:GetPlayers()) do
			player.Character.HumanoidRootPart.CFrame = workspace.Part.CFrame
		end
else--if not true then
		for _,player in pairs(game.Players:GetPlayers()) do
			player.Character.HumanoidRootPart.CFrame = workspace.hs.CFrame
		end
	end
end)

local function round()
	wait(1)
	gamestring.Value = "Game will start soon" --starting text
	wait(30)
	gamestring.Value = "Game Started"
	wait(0.25)
	gamestring.Value = " "
	wait(1)
	cantp.Value = true -- changeing the  boolean value
	gear:Clone().Parent = game.Players.LocalPlayer.BackPack---putting item in bacpack
	wait(30)
	cantp.Value = false -- changeing the boolean value
	game.Players.LocalPlayer.BackPack.Wacker:Remove()
	end

while true do
	round()
	wait(1)
end

Don’t know much about this type of stuff but you could try this:

Also is this a server script or local script?

Server script inside serverscriptservice

From my understanding, you’re trying to get the localPlayer on the server.

Local players can only be called on the client/ locally, as the server handles all the players, whereas the client only handles the 1 (itself).

To fix this, I’d recommend another for pairs loop (the one within the Changed Event). It should look something like this.

local cantp = game.ReplicatedStorage.cantp
local gear = game.ServerStorage.Wacker

cantp.Changed:Connect(function()--when the boolean is changed then do
if cantp.Value == true then--if true then/always add .Value for boolean or intvalue
		for _,player in pairs(game.Players:GetPlayers()) do
			player.Character.HumanoidRootPart.CFrame = workspace.Part.CFrame
		end
else--if not true then
		for _,player in pairs(game.Players:GetPlayers()) do
			player.Character.HumanoidRootPart.CFrame = workspace.hs.CFrame
		end
	end
end)

local function round()
	wait(1)
	gamestring.Value = "Game will start soon" --starting text
	wait(30)
	gamestring.Value = "Game Started"
	wait(0.25)
	gamestring.Value = " "
	wait(1)
	cantp.Value = true -- changeing the  boolean value
	for i, player in pairs(game.Players:GetPlayers()) do
        gear:Clone().Parent = player.Backpack
    end
 	wait(30)
	cantp.Value = false -- changeing the boolean value
	game.Players.LocalPlayer.BackPack.Wacker:Remove()
	end

while true do
	round()
	wait(1)
end

You may need to fix this code if there’s any errors afterwards, but this should work.

1 Like

hey i changed it

local gamestring = game.ReplicatedStorage.GameString
local cantp = game.ReplicatedStorage.cantp
local gear = game.ServerStorage.Wacker

cantp.Changed:Connect(function()–when the boolean is changed then do
if cantp.Value == true then–if true then/always add .Value for boolean or intvalue
for _,player in pairs(game.Players:GetPlayers()) do
player.Character.HumanoidRootPart.CFrame = workspace.Part.CFrame
end
else–if not true then
for _,player in pairs(game.Players:GetPlayers()) do
player.Character.HumanoidRootPart.CFrame = workspace.hs.CFrame
end
end
end)

local function round()
wait(1)
gamestring.Value = “Game will start soon” --starting text
wait(30)
gamestring.Value = “Game Started”
wait(0.25)
gamestring.Value = " "
wait(1)
cantp.Value = true – changeing the boolean value
for i, player in pairs(game.Players:GetPlayers()) do
gear:Clone().Parent = player.Backpack—putting item in bacpack
wait(30)
cantp.Value = false – changeing the boolean value
for i, player in pairs(game.Players:GetPlayers()) do
player.Backpack.Wacker:Remove()
end

while true do
round()
wait(1)
end

but still not work

Wdym “it won’t work”, please try to be more descriptive. Is nothing happening? Is it saying “Game Started” but not doing anything? Is there an error/warning on the console?

no error but the round text is not working or no code it working