Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Flip265 -14
4 years ago

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

1
Hold Alt+F4 Edbotikx 99 — 4y

Closed as Not Constructive by Fifkee, GeneratedScript, and DeceptiveCaster

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
Norbunny 555 Moderation Voter
4 years ago

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)
0
Thx Norbunny Flip265 -14 — 4y
Ad