I am trying to make a clothing script that make the player wear the clothes they were previously wearing before they died and It does not work. I don’t know what to do. I did It with a local script before but I want it to use a sever script so that it is more secure. I got an error saying “Argument 1 missing or nil”. (I have more than 1 shirt in CheckAndFire function. I didn’t want people reading a long script )
Local Script(Old)
local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local shirt = player:WaitForChild("aye"):WaitForChild("shirt")
local function checkAndFire()
if shirt.Value == "whitesleeve" then
ReplicatedStorage.Events.ShirtEvent5:FireServer()
end
end
checkAndFire() --Run when player joins
player.CharacterAdded:Connect(checkAndFire)
Local Script
--Used to start the event in the serverscript below
local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
player.CharacterAdded:Connect(function()
ReplicatedStorage.Events.CheckEvent:FireServer()
end)
Server Script(What I tried)
game.ReplicatedStorage.Events.ShirtEvent5.OnServerEvent:Connect(function(plr)
local char = plr.Character
local q = BrickColor.new("White")
local Tors = char["UpperTorso"]
Tors.BrickColor = q
end)
game.ReplicatedStorage.Events.CheckEvent.OnServerEvent:Connect(function(plr)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local shirt = plr:WaitForChild("aye"):WaitForChild("shirt")
local function checkAndFire()
if shirt.Value == "whitesleeve" then
ReplicatedStorage.Events.ShirtEvent5:FireClient()
end
end
checkAndFire()
end)