I want to get a player from a team and see if the name of that player is the exact same as the value of an objectvalue but it does not seem to work. Sorry if my code seems sloppy will try and fix it later.
local collector = script.Parent
collector.Touched:Connect(function(hit)
local findgold = hit:FindFirstChildOfClass("IntValue")
if findgold then
local OwnerName = game.Workspace.Tycoon1.OwnerValue.Value
local Owner = game.Teams.France:GetPlayers()
if Owner.Name == OwnerName then
local leaderstats = Owner:FindFirstChild("leaderstats")
if leaderstats then
local gold = leaderstats:FindFirstChild("Gold")
gold.Value += findgold.Value
end
end
end
end)
local teams = game:GetService("Teams")
local team = teams.Team
local objectValue = workspace.ObjectValue --Example reference.
for _, teamPlayer in ipairs(team:GetPlayers()) do
if objectValue.Value == teamPlayer then
--Do code.
end
end
local Owner = game.Workspace.Tycoon1.OwnerValue.Value
local OwnerTeam = game.Teams.France
if Owner.Team == OwnerTeam then
local leaderstats = Owner:FindFirstChild("leaderstats")
if leaderstats then
local gold = leaderstats:FindFirstChild("Gold")
gold.Value += findgold.Value
end
end