Script's inside ServerScriptService count's to all players or it counts for the local player?

I am trying to make it so that when a player clicks on a button, it turns into a character, in which case it would be a StarterCharacter. But the problem is, it seems, that it’s turning them all into the same character and I just want that for the player who clicked it.

– LocalScript inside an ImageButton

local Player = game:GetService("Players").LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	if Player.leaderstats.Rank.Value == "Security Corporal" then
		game.ReplicatedStorage.Event.Morpher:FireServer("Corporal")
	end
end)

– Script inside ServerScriptService

local ServerStorage = game:GetService("ServerStorage")

game.ReplicatedStorage.Event.Morpher.OnServerEvent:Connect(function(player, rankName)
	if rankName == "Cadet" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1Cadet:Clone()
		local L2 = ServerStorage.Itens["[NC] Level-2"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L2.Parent = player.Backpack
		LC.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "Junior" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1Junior:Clone()
		local L2 = ServerStorage.Itens["[NC] Level-2"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local P90 = ServerStorage.Itens.P90:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L2.Parent = player.Backpack
		LC.Parent = player.Backpack
		P90.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "Guard" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1Guard:Clone()
		local L2 = ServerStorage.Itens["[NC] Level-2"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local P90 = ServerStorage.Itens.P90:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L2.Parent = player.Backpack
		LC.Parent = player.Backpack
		P90.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "SenGuard" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1Senior2Guard:Clone()
		local L2 = ServerStorage.Itens["[NC] Level-2"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local P90 = ServerStorage.Itens.P90:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L2.Parent = player.Backpack
		LC.Parent = player.Backpack
		P90.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "Corporal" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1Corporal:Clone()
		local L2 = ServerStorage.Itens["[NC] Level-2"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local P90 = ServerStorage.Itens.P90:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L2.Parent = player.Backpack
		LC.Parent = player.Backpack
		P90.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "Sergeant" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1Sergeant:Clone()
		local L2 = ServerStorage.Itens["[NC] Level-2"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local P90 = ServerStorage.Itens.P90:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L2.Parent = player.Backpack
		LC.Parent = player.Backpack
		P90.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "SerMajor" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1Sergeant2Major:Clone()
		local L2 = ServerStorage.Itens["[NC] Level-2"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local P90 = ServerStorage.Itens.P90:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L2.Parent = player.Backpack
		LC.Parent = player.Backpack
		P90.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "Officer" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1Officer:Clone()
		local L3 = ServerStorage.Itens["[NC] Level-3"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local M4 = ServerStorage.Itens.M4:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L3.Parent = player.Backpack
		LC.Parent = player.Backpack
		M4.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "Lieutenant" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1Lieutenant:Clone()
		local L3 = ServerStorage.Itens["[NC] Level-3"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local M4 = ServerStorage.Itens.M4:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L3.Parent = player.Backpack
		LC.Parent = player.Backpack
		M4.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "Captain" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1Captain:Clone()
		local L3 = ServerStorage.Itens["[NC] Level-3"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local M4 = ServerStorage.Itens.M4:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L3.Parent = player.Backpack
		LC.Parent = player.Backpack
		M4.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "Major" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1Major:Clone()
		local L3 = ServerStorage.Itens["[NC] Level-3"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local M4 = ServerStorage.Itens.M4:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L3.Parent = player.Backpack
		LC.Parent = player.Backpack
		M4.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "Colonel" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1Colonel:Clone()
		local L3 = ServerStorage.Itens["[NC] Level-3"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local M4 = ServerStorage.Itens.M4:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L3.Parent = player.Backpack
		LC.Parent = player.Backpack
		M4.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "General" then
		local Morph = ServerStorage.Morph.SED.Morphs.Security1General:Clone()
		local L4 = ServerStorage.Itens["[NC] Level-4"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local M4 = ServerStorage.Itens.M4:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L4.Parent = player.Backpack
		LC.Parent = player.Backpack
		M4.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "SB-Soldier" then
		local Morph = ServerStorage.Morph.SED.SB.Sentinel1Soldier2Elite:Clone()
		local L2 = ServerStorage.Itens["[NC] Level-2"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local Hk33 = ServerStorage.Itens.Hk33:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L2.Parent = player.Backpack
		LC.Parent = player.Backpack
		Hk33.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "SB-Officer" then
		local Morph = ServerStorage.Morph.SED.SB.Sentinel1Officer2Elite:Clone()
		local L3 = ServerStorage.Itens["[NC] Level-3"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local Hk33 = ServerStorage.Itens.Hk33:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L3.Parent = player.Backpack
		LC.Parent = player.Backpack
		Hk33.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "SB-Col" then
		local Morph = ServerStorage.Morph.SED.SB.Sentinel1Commander1Elite:Clone()
		local L3 = ServerStorage.Itens["[NC] Level-3"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local Hk33 = ServerStorage.Itens.Hk33:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L3.Parent = player.Backpack
		LC.Parent = player.Backpack
		Hk33.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "RC-Soldier" then
		local Morph = ServerStorage.Morph.SED.RCU.Riot1Soldier:Clone()
		local L2 = ServerStorage.Itens["[NC] Level-2"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local Hk33 = ServerStorage.Itens.Hk33:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Shield = ServerStorage.Itens.EscudoRiot:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L2.Parent = player.Backpack
		LC.Parent = player.Backpack
		Hk33.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Shield.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "RC-Officer" then
		local Morph = ServerStorage.Morph.SED.RCU.Riot1Officer:Clone()
		local L3 = ServerStorage.Itens["[NC] Level-3"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local Hk33 = ServerStorage.Itens.Hk33:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Shield = ServerStorage.Itens.EscudoRiot:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L3.Parent = player.Backpack
		LC.Parent = player.Backpack
		Hk33.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Shield.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "RC-Col" then
		local Morph = ServerStorage.Morph.SED.RCU.Commander1Riot:Clone()
		local L3 = ServerStorage.Itens["[NC] Level-3"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local Hk33 = ServerStorage.Itens.Hk33:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Shield = ServerStorage.Itens.EscudoRiot:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L3.Parent = player.Backpack
		LC.Parent = player.Backpack
		Hk33.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Shield.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "MRU-Soldier" then
		local Morph = ServerStorage.Morph.SED.MRU.Medical1Soldier
		local L2 = ServerStorage.Itens["[NC] Level-2"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local MP5 = ServerStorage.Itens.MP5:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L2.Parent = player.Backpack
		LC.Parent = player.Backpack
		MP5.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "MRU-Officer" then
		local Morph = ServerStorage.Morph.SED.MRU.Medical1Officer
		local L3 = ServerStorage.Itens["[NC] Level-3"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local MP5 = ServerStorage.Itens.MP5:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L3.Parent = player.Backpack
		LC.Parent = player.Backpack
		MP5.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	elseif rankName == "MRU-Col" then
		local Morph = ServerStorage.Morph.SED.MRU.Medical1Commander
		local L3 = ServerStorage.Itens["[NC] Level-3"]:Clone()
		local LC = ServerStorage.Itens["[NC] Level-C"]:Clone()
		local MP5 = ServerStorage.Itens.MP5:Clone()
		local Beretta = ServerStorage.Itens["Beretta 92fs"]:Clone()
		local Radio = ServerStorage.Itens.Radio:Clone()
		Morph.Name = "StarterCharacter"
		Morph.Parent = game.StarterPlayer
		player:LoadCharacter()
		L3.Parent = player.Backpack
		LC.Parent = player.Backpack
		MP5.Parent = player.Backpack
		Beretta.Parent = player.Backpack
		Radio.Parent = player.Backpack
	end
end)

Your script should work, but pay attention to the way you call the event, in the ServerScriptService script, you declare 2 arguments: player and rank, but when you call the event, you only pass the rank, and the script will assume the rank is the player, try calling the event like this:

local Player = game:GetService("Players").LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	if Player.leaderstats.Rank.Value == "Security Corporal" then
		game.ReplicatedStorage.Event.Morpher:FireServer(Player, "Corporal")
	end
end)

Nevermind, I wasn’t paying attention

1 Like

I’m sorry, but you are wrong, since RemoveEvent 1 argument ALWAYS is the player who called the event.
Docs: RemoteEvent | Roblox Creator Documentation


Therefore, it is not necessary to transfer the player himself in the event.

local Player = game:GetService("Players").LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	if Player.leaderstats.Rank.Value == "Security Corporal" then
		game.ReplicatedStorage.Event.Morpher:FireServer("Corporal")
	end
end)
3 Likes

Then how I would resolve the problem?

Does it have anything to do with the fact that you’re adding the morphs to StarterPlayer?

Since this is server-sided, it will be moved for all players

1 Like

I’m new with messing StarterCharacter, as I always used another ways to morph an user. However, I wanted to use it for more simpler which is StarterCharacter.

Yeah, it’s an script that’s why it’s my main suspect on why it’s going to every player, so that’s why my post title is like that.
Another point, it shouldn’t the StarterCharacter going inside to the StarterPlayer to work?

This is the problem, you need to copy what you have into his character for each player when spawning.

1 Like

The problem is, I can’t as the local doesn’t let me without being called in a backend server.
image

You must use this on the server… (e.g. when sending an event)

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