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
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.
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
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.
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)
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().