Team Issue & Sound Issue inside the Teamselection UI

Hello, I’m currently trying to make a New Menu. However, i’m having some Issue with the Teaming & :GetRoleInGroup() inside the Local Script & Server Script. I haven’t found any issue, and its already preatty late. So if anyone got a way to fix it, feel free to shar it.

Issues

  1. Teaming of Players.
    The Script does not correctly Team the Player to the given Team. I’m unsure why.
    Error Output can be seen on the picture.

  2. Sound effects do not Play.
    The Local Script does not Play any Sounds of the Teams that are connected with a Group.
    The Output of the Error is also shown in the pic.

Code & Pictures

Here is the Server Script Code:

function clicked(User)
	if script.Parent.Text == "WCKD Personnel" then
		if User:GetRoleInGroup(6875411) >= 3 then
			User.Team = game.Teams:FindFirstChild(script.Parent.Text)
			--script.Parent.Parent:FindFirstChild("00000000001").Text = "Selected: ".. script.Parent.Text
		end
	elseif script.Parent.Text == "WCKD Security Force" then
		if User:GetRoleInGroup(6875830) >= 1 then
			User.Team = game.Teams:FindFirstChild(script.Parent.Text)
			--script.Parent.Parent:FindFirstChild("00000000001").Text = "Selected: ".. script.Parent.Text
		end
	elseif script.Parent.Text == "WCKD Security Units" then
		if User:GetRoleInGroup(6875830) >= 16 and User:GetRoleInGroup(6875830) <= 20 then
			User.Team = game.Teams:FindFirstChild(script.Parent.Text)
			--script.Parent.Parent:FindFirstChild("00000000001").Text = "Selected: ".. script.Parent.Text
		end
	elseif script.Parent.Text == "[CLASSIFIED]" then
		if User:GetRoleInGroup(7071484) >= 10 then
			User.Team = game.Teams:FindFirstChild(script.Parent.Text)
			--script.Parent.Parent:FindFirstChild("00000000001").Text = "Selected: ".. script.Parent.Text
		end
	else
		User.Team = game.Teams:FindFirstChild(script.Parent.Text)
		--script.Parent.Parent:FindFirstChild("00000000001").Text = "Selected: ".. script.Parent.Text
	end
end

script.Parent.MouseButton1Click:Connect(clicked)

Here is the Local Script Code:

function clicked(User)
	wait()	
	if script.Parent.Text == "WCKD Personnel" then
		if User:GetRoleInGroup(6875411) >= 3 then
			script.Parent.Parent.Parent.Select:Play()
		else
			script.Parent.Parent.Parent.Denied:Play()
		end
	elseif script.Parent.Text == "WCKD Security Force" then
		if User:GetRoleInGroup(6875830) >= 1 then
			script.Parent.Parent.Parent.Select:Play()
		else
			script.Parent.Parent.Parent.Denied:Play()
		end
	elseif script.Parent.Text == "WCKD Security Units" then
		if User:GetRoleInGroup(6875830) >= 16 and User:GetRoleInGroup(6875830) <= 20 then
			script.Parent.Parent.Parent.Select:Play()
		else
			script.Parent.Parent.Parent.Denied:Play()
		end
	elseif script.Parent.Text == "[CLASSIFIED]" then
		if User:GetRoleInGroup(7071484) >= 10 then
			script.Parent.Parent.Parent.Select:Play()
		else
			script.Parent.Parent.Parent.Denied:Play()
		end
	else
		script.Parent.Parent.Parent.Select:Play()
	end
end

script.Parent.MouseButton1Click:Connect(clicked)


function hover()
	script.Parent.Parent.Parent.Hover:Play()
end

script.Parent.MouseEnter:Connect(hover)

Here the Button cloner Script:

wait()
for _,V in pairs(game.Teams:GetChildren()) do
	wait()
	local Button = script.Parent.Parent.Examplebutton:Clone()
	Button.Parent = script.Parent
	Button.Name = V.Name
	Button.Text = V.Name
	Button.Visible = true
end

Server output

Client output
Model Placement
Screenshot_9

1 Like

Because MouseButton1Click doesn’t have a parameter of the Player. Also, please listen for client input in a local script instead of server script.

If also tryed by Searching for the Player.
Didn’t work too.

I’ll try once more.
also, What do you mean with “please listen for client input in a local script instead of server script.”

You are listening inputs from a client in a server script. You need to use a local script.

I’m having 2.

1 Server Script
1 Local Script

and bouth do not work.

The Scripts are also still using the old name “Examplebutton” even too it has already changed.

Because there is no parameter for the MouseButton1Click . It does not return the player because you can get player from a local script with game.Players.LocalPlayers . That is why you shouldn’t listen inputs in a server script. You need to use RemoteEvents.

Does also not work with “Localplayer”
Tryed already before.

function clicked()
	local User = game.Players.LocalPlayer
	print("Sound Script: ".. User.Name)
	
	wait()	
	if script.Parent.Text == "WCKD Personnel" then
		if User:GetRoleInGroup(6875411) >= 3 then
			script.Parent.Parent.Parent.Select:Play()
		else
			script.Parent.Parent.Parent.Denied:Play()
		end
	elseif script.Parent.Text == "WCKD Security Force" then
		if User:GetRoleInGroup(6875830) >= 1 then
			script.Parent.Parent.Parent.Select:Play()
		else
			script.Parent.Parent.Parent.Denied:Play()
		end
	elseif script.Parent.Text == "WCKD Security Units" then
		if User:GetRoleInGroup(6875830) >= 16 and User:GetRoleInGroup(6875830) <= 20 then
			script.Parent.Parent.Parent.Select:Play()
		else
			script.Parent.Parent.Parent.Denied:Play()
		end
	elseif script.Parent.Text == "[CLASSIFIED]" then
		if User:GetRoleInGroup(7071484) >= 10 then
			script.Parent.Parent.Parent.Select:Play()
		else
			script.Parent.Parent.Parent.Denied:Play()
		end
	else
		script.Parent.Parent.Parent.Select:Play()
	end
end

script.Parent.MouseButton1Click:Connect(clicked)


function hover()
	script.Parent.Parent.Parent.Hover:Play()
end

script.Parent.MouseEnter:Connect(hover)

Output

also tryed for Server Script with a ObjectValue.
Did also not work.

The main Issue for the Server Script Looks like it doesn’t Update with the new Informations, even too the funnction is only runned on a click.

If this is a server script, game.Players.LocalPlayer won’t work.

Its a local Script
That it won’t work for Server Script i’m awear off.

Then is the server listening for a RemoteEvent to fire?

Negative, this with the Remoteevent is why I try right now.

Can I see what changes you did in the local and server script?

Error Server Side (Complite new Script)

Server Script (New)

function clicked(plr)
	if script.Parent.Text == "WCKD Personnel" then
		if plr:GetRoleInGroup(6875411) >= 3 then
			script.Parent.Parent:FindFirstChild("00000000001").Text = script.Parent.Text
			print(plr)
			plr.Team = game.Teams:FindFirstChild(script.Parent.Text)
		end
	elseif	script.Parent.Text == "WCKD Security Force" then
		if plr:GetRoleInGroup(6875830) >= 1 then
			script.Parent.Parent:FindFirstChild("00000000001").Text = script.Parent.Text
			print(plr)
			plr.Team = game.Teams:FindFirstChild(script.Parent.Text)
		end
	elseif	script.Parent.Text == "WCKD Security Units" then
		if plr:GetRoleInGroup(6875830) >= 16 and plr:GetRoleInGroup(6875830) <= 20 then
			script.Parent.Parent:FindFirstChild("00000000001").Text = script.Parent.Text
			print(plr)
			plr.Team = game.Teams:FindFirstChild(script.Parent.Text)
		end
	elseif	script.Parent.Text == "[CLASSIFIED]" then
		if plr:GetRoleInGroup(7071484) >= 10 then
			script.Parent.Parent:FindFirstChild("00000000001").Text = script.Parent.Text
			print(plr)
			plr.Team = game.Teams:FindFirstChild(script.Parent.Text)
		end
	end
end

script.Parent.info.OnServerEvent:Connect(clicked)

function enter()
	script.Parent.TextColor3 = Color3.new(255, 0, 255)
end

script.Parent.MouseEnter:Connect(enter)


function leave()
	script.Parent.TextColor3 = Color3.new(255, 255, 255)
end

script.Parent.MouseLeave:Connect(leave)

Local Script (New)

function clicked()
	if script.Parent.Parent.Parent.Select.playing == false then
		script.Parent.Parent.Parent.Select:Play()
	end
	script.Parent.info:FireServer()
end

script.Parent.MouseButton1Click:Connect(clicked)

function hover()
	script.Parent.Parent.Parent.Hover:Play()
end

script.Parent.MouseEnter:Connect(hover)

The Game can be visited here:

WCKD | Menu System - Roblox

GetRoleInGroup returns the name of the role which is a string. If you need to compare the rank, do GetRankInGroup

Ye, seen that too.
Already fixed that issue.

However, it does still not Team.
You want the 2 new Scripts to see?

I’ll get for the Team always just “Nil” even to i’ll search for it.

If the there is no Team associated with the FindFirstChild, it won’t work. You can change the team via the name or the TeamColor. For the TeamColor, do Player.TeamColor = BrickColor.new().

It did work with Plr.Team now. (FindFirstChild()

Just sent a wrong Information via the Event.
It works fine now, however thank you anyways.

1 Like