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

GUI Script For Team Selector GUI Cause i Can't coding to much :( how then?

I want to make a Team selector GUI Like prison life,Jailbreak,Redwood prison but how?

1 comment

1

Hold Alt+F4

1 answer

✓ Accepted answer

I'd recommend having a look at these, they will help you understand more about Roblox's API and coding on Roblox.

https://developer.roblox.com/en-us/api-reference/class/Teams https://developer.roblox.com/en-us/api-reference/class/RemoteEvent

GUI's are client sided, so the LocalScript located in your GUI will handle client-sided input, the click, etc. You will need to fire a RemoteEvent to tell the server to change a user's team.

-- Local script
-- To be placed in your GUI

-- RemoteEvents shall be parented to ReplicatedStorage
local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage:WaitForChild("YourEvent") -- The name of your remoteEvent

local gui = script.Parent

-- variables for your team's buttons
local teamAButton = gui.Button
local teamBButton = gui.Button2

-- Listening to the mouse's click
teamAButton.MouseButton1Click:Connect(function() 
    event:FireServer("TeamA") -- Fire the server with the team to be changed to
end)

teamBButton.MouseButton1Click:Connect(function() 
    event:FireServer("TeamB")
end)

And that's it for the client. Now we'll script the server's part. Once again, make sure to read the documentation on the topics you don't understand!

-- Script
-- To be placed in the ServerScriptService

local replicatedStorage = game:GetService("ReplicatedStorage")
local teams = game:GetService("Teams") -- The teams service

-- Creating the RemoteEvent
local event = Instance.new("RemoteEvent")
event.Name = "YourEvent" -- The RemoteEvent's name
event.Parent = replicatedStorage

event.OnServerEvent:Connect(function(player, arg1) 
	-- The first argument is ALWAYS the player who fired the event 

	-- A RemoteEvent can pass many arguments, however, we are only listening to 1, the team.
	
	local team = teams[arg1] -- Finding the team the player asked to be moved to
	
	if(team) then  -- if the team exists
		player.Team = team
	end
end)

1 comment

0

Thx Norbunny

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