How To Turn Client to Server

I am trying to make a team changer where you hit the job and ui pop up. Then if you hit get tag it. switches your team to that job.

All of this works accept the tag does not change. It will only appear on the client’s side, not for the whole server. It will only appear on client, because it’s in StarterCharacterScripts where LocalScripts are supposed to be.

They way to do this is to place a Script (not a LocalScript) in Workspace or ServerScriptService

How do I make this in to a server script?

-- SERVER SCRIPT INSIDE STARTERCHARACTERSCRIPTS
---> services
local char = script.Parent
local plr = game.Players:GetPlayerFromCharacter(char)

---> variables
local NameTagClone = game.ServerStorage.HeadUI:Clone()

---> main
NameTagClone.Parent = char.Head
NameTagClone.Adornee = char.Head

NameTagClone.UI.NameUI.NameName.Text = char.Name

if plr.Team == nil then
	NameTagClone.UI.RankUI.RankName.Text = "Player"
end

repeat wait() until plr.Team ~= nil

NameTagClone.UI.RankUI.RankName.Text = plr.Team.Name

char.Humanoid.DisplayDistanceType = "None"

game:GetService("RunService").Heartbeat:Connect(function()
	NameTagClone.UI.RankUI.RankName.Text = plr.Team.Name
end)
2 Likes

look into remoteevents. you should set the team on a serverscript once the remoteevent receives the request

I know but I don’t know how to do that

that’s good because there’s documents specifically made for people that don’t know how to do things RemoteEvent | Documentation - Roblox Creator Hub look at fireserver and onserverevent

Wait so I use the FireServer in the local script and OnServerEvent on the server script

yes you use :fireserver(info) as an event and then .onserverevent:connect(function(player, info) as a listener, you can send tables or multiple arguments

How do I get the players head in a sever script. I know how to get the players with

local Players = game:GetService("Players")

But I don’t know how to get each player

Wait I don’t need remote event because the script just clones the UI to the players head and updates the UI

Are you looking for this?

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		---> variables
		local NameTagClone = game.ServerStorage.HeadUI:Clone()

		---> main
		NameTagClone.Parent = char.Head
		NameTagClone.Adornee = char.Head

		NameTagClone.UI.NameUI.NameName.Text = char.Name

		if plr.Team == nil then
			NameTagClone.UI.RankUI.RankName.Text = "Player"
		end

		repeat wait() until plr.Team ~= nil

		NameTagClone.UI.RankUI.RankName.Text = plr.Team.Name

		char.Humanoid.DisplayDistanceType = "None"

		game:GetService("RunService").Heartbeat:Connect(function()
			NameTagClone.UI.RankUI.RankName.Text = plr.Team.Name
		end)
	end)
end)

Yesssss!!! Thank You!!!--------

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.