How to make this aura system server sided?

Confused on how to make this SS/ServerSided? Lua is below.

local AuraHead = game.ReplicatedStorage.YakuzaAura.Head.Aura
local AuraLeftArm = game.ReplicatedStorage.YakuzaAura.LeftArm.Aura
local AuraRightArm = game.ReplicatedStorage.YakuzaAura.RightArm.Aura
local AuraTorso = game.ReplicatedStorage.YakuzaAura.Torso.Aura
local AuraRightLeg = game.ReplicatedStorage.YakuzaAura.RightLeg.Aura
local AuraLeftLeg = game.ReplicatedStorage.YakuzaAura.LeftLeg.Aura

local holdAnim = 7411214073
local holdAnim2 = 7411184629

repeat wait() until game.Players.LocalPlayer.Character
local lp = game.Players.LocalPlayer
local sp = script.Parent


sp.Equipped:connect(function(player)	
	player.Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=6522933298"
	player.Character.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=2389321787"
	local headClone = AuraHead:Clone()
	headClone.Parent = player.Character.Head
	local TorsoClone = AuraTorso:Clone()
	TorsoClone.Parent = player.Character.Torso
	local LeftArmClone = AuraLeftArm:Clone()
	LeftArmClone.Parent = player.Character["Left Arm"]
	local RightArmClone = AuraRightArm:Clone()
	RightArmClone.Parent = player.Character["Right Arm"]
	local RightLegClone = AuraRightLeg:Clone()
	RightLegClone.Parent = player.Character["Right Leg"]
	local LeftLegClone = AuraLeftLeg:Clone()
	LeftLegClone.Parent = player.Character["Left Leg"]
	wait(0.3)
	
	player.Character.Humanoid.WalkSpeed = 22.5



	
end)

sp.Unequipped:connect(function(player)
	player.Character.Humanoid.WalkSpeed = 16
end)

image

1 Like

Provided this is a tool, you can use a ServerScript just fine by changing up some of the reference variables to your player and respective character. Remember when a player spawns and has tools put into their backpack you can find the player pretty easily by going up the hierarchy tree.

The backpack will be the tool’s parent.
So long as it is not INSTANTLY equipped by the player using :EquipTool()

The player will be the backpack’s parent.

Changing up some of these variables will fix this script for use on the server. :+1:

I’m still really confused about it.
like can you point out some of the variables to change?

This here is where you need to alter. Think about the ancestry of your script and how you can traverse through the ancestry tree to get up to a higher level; where your player will be.

Instead, of using a “LocalPlayer” as Nidoxs said you could change it up because LocalPlayer doesn’t work on the server however PlayerAdded does.

I mean if you are suffering from doing localplayer from the server side then you can do game.Players.PlayerAdded:Connect(function(plr)

One method to make this server sided is by using RemoteEvents. When you equip the tool, signal a RemoteEvent sending only the Player from the local script, and doing stuff you need to change in the script receiving the signal.

This is one of many methods you can use. I’ve been doing this most of the time when it comes to tools and other jazz.

So I suck with remote events so thats gonna be very confusing.

Well, you can fetch the character from the .Equipped event (the tools parent)
One of the most secure ways to make tools that don’t require the use of the client’s Mouse.

local Char --gonna become the character later on
local Humanoid

Tool.Equipped:Connect(function()
     Char = Tool.Parent --since the tool is a child of the char when equipped
     Humanoid = Char:WaitForChild("Humanoid") --now you have the characters humanoid
end)

Tool.Unequipped:Connect(function()
     --still have reference to the char and humanoid since they're global variables
end)

You can convert the character to a player/user using game.Players:GetPlayerFromCharacter(Character: Model).
And you can also check if Char and Humanoid are nil, if they aren’t you don’t have to set it once again.

Slight grammar mistakes.

AND if you are doing PlayerAdded with something like this:

local Player

game.Players.PlayerAdded:Connect(function(User)
    Player = User
end)

Please bear in mind the player variable is able to be changed to anyone that joins the game, and will not be the local player that joined.

I’ve tried all of these still not working tools are very confusing.

A remoteEvent is communication between the server and client. So you could fire a remoteEvent from the client to the server (server executes code when client fires the event). That way you can listen for the equipped event and still make some code on the server
to fire a client from the client when a player equips the tool you can do:
Client:

local player = game.Players.LocalPlayer
local tool = script.Parent
local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")

tool.Equipped:Connect(function()
    remoteEvent:FireServer()--fire the event
end)

For server, you want to listen to the event and receive it when it gets fired:

local remoteEvent = Instance.new("RemoteEvent", game.ReplicatedStorage)

remoteEvent.OnServerEvent:Connect(function(player) --player is the argument passed through the event by the client
--do your code here
local char = player.Character
--local clone = ...:Clone()
--clone.Parent = char
--etc.
end)

remoteEvent wiki

1 Like

Just like how @HitCraftPizzeria demonstrated. This is one of the most reliable way of firing from client to server. But do keep in mind the client/server “lag.” This can make your player’s character choppy, especially when your are attaching something to the physical character itself (from the server side).