--// DECLARING VARIABLES \\-- local textBox = game.StarterGui.Events.Event local textValue = game.StarterGui.Events.Value.Value local toolGive = game:WaitForChild("ReplicatedStorage").Tool1:Clone() local teamsService = game:GetService("Teams") local playersService = game:GetService("Players") --// STARTING \\-- playersService.PlayerAdded:Connect(function(player) textBox.Text = textValue while true do textBox.Text = textValue textValue = "Free Time" wait(1) textBox.Text = textValue textValue = "Testing Time" wait(1) textBox.Text = textValue textValue = "Riot Time" if player.Team.Name == "Team 1" then toolGive.Parent = player:WaitForChild("Backpack") end wait(1) end end)
I made this script and I had to access the LocalPlayer and this is not a localscript, so I decided to make the function game.Players.PlayerAdded:Connect(function(player) , but after I did that nothing was working.
Issue 1: In a local
Variable, if we want to change the Value of a ValueObject
we NEVER use the .Value
property in a variable. Instead, the .Value
property should be used later, as I state below:
Issue 2: We don't use a string to change teams, the preferred way is to use game:GetService("Teams")
and the team name here. There are some times that it won't work using a string.
--// DECLARING VARIABLES \\-- local textBox = game.StarterGui.Events.Event local textValue = game.StarterGui.Events.Value -- We don't use the .value property here, we set the value object so we can change the value later local toolGive = game:WaitForChild("ReplicatedStorage").Tool1:Clone() local teamsService = game:GetService("Teams") local playersService = game:GetService("Players") --// STARTING \\-- playersService.PlayerAdded:Connect(function(player) textBox.Text = textValue.Value while true do textValue.Value = "Free Time" textBox.Text = textValue.Value wait(1) textValue.Value = "Testing Time" textBox.Text = textValue.Value wait(1) textValue.Value = "Riot Time" textBox.Text = textValue.Value if player.Team.Name == "Team 1" then toolGive.Parent = player:WaitForChild("Backpack") end wait(1) end end)
Tell me if there are still more issues, and hope it helps you!