Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My player's team won't change to what I want it to be?

So I have a script that I want it so only 1 shark can join and only 9 fish can join their team. The max amount of players in a server is 10. This script isn;t changing my team to sharks and I don't know why. This script is a local script inside a frame in a screengui in startergui.

local plr = game.Players.LocalPlayer
clicked = false
clicked2 = false
click1 = script.Parent:WaitForChild("Click1")
click2 = script.Parent:WaitForChild("Click2")

script.Parent.JoinSharks.MouseButton1Click:connect(function()
	if clicked == false then
		if workspace.SharksFull == false then
			plr.TeamColor = BrickColor.new("Cyan")
			if workspace.GameHasStarted.Value == false then
				local spawns = workspace.SharkSpawn
				plr.Character.Torso.CFrame = CFrame.new(spawns.Position)
			end
		end
	end
	clicked = true
end)

script.Parent.JoinFish.MouseButton1Click:connect(function()
	click1.Value = click1.Value + 1
	plr.TeamColor = BrickColor.new("Bright orange")
	if workspace.GameHasStarted.Value == false then
		local spawns = workspace.FishieSpawns:GetChildren()
		local chosenspawn = spawns[math.random(1,#spawns)]
		plr.Character.Torso.CFrame = CFrame.new(chosenspawn.Position)
	end
end)

1 answer

✓ Accepted answer

On line 9 use workspace.SharksFull.Value. workspace.SharksFull is not a valid member of workspace and will error, and .Value is needed to get the value of a BoolValue object.

3 comments

0

WHERE IS THE EXPLANATION!

0

Fixed it.

0

That's better. I hope you learned your lesson.

This discussion is preserved as it was. New answers, comments, and votes are closed.