Detection for player added event does work

  1. What do you want to achieve? Keep it simple and clear!
    whenever the player is added a “Case” will be added to the character

  2. What is the issue? Include screenshots / videos if possible!
    it doesn’t detect and doesn’t add it and doesn’t print “Player added should add case”

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i did it brought up this module that was kinda complicated for me. i just wanted to add a player added function it doesn’t seem to work and it worked before

full Script:

--//services
local RP = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

--//Variables
local CaseRP = RP.Models.Case

--// Player/Char
local Player = Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local Torso = Char:WaitForChild("Torso")
local TorsoCF = Torso.CFrame

local AddCase = RP.Events.AddCase

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		print("Player added should add case")
		AddCase:FireServer(CaseRP, char:WaitForChild("Torso"), char:WaitForChild("Torso").CFrame)
	end)
end)
-- server script
game:GetService("ReplicatedStorage").Events.AddCase.OnServerEvent:Connect(function(plr, CaseRP, Torso, TorsoCF)
	local Char = plr.Character
	--//Case
	local Case = CaseRP:Clone()
	Case:SetPrimaryPartCFrame(TorsoCF)
	Case.Parent = Char

	--//Motor6D
	local Motor = Instance.new("ManualWeld")
	Motor.Parent = Torso
	Motor.Name = "CaseMotor6D"
	Motor.C0 = Case.PrimaryPart.CFrame
	Motor.C1 = TorsoCF
	Motor.Part0 = Torso
	Motor.Part1 = Case.PrimaryPart
	
	local LeftHand = Instance.new("Part", plr.Character["Left Arm"])
	LeftHand.Name = "LeftHandHitBox"
	LeftHand.Transparency = 1
	LeftHand.Size = Vector3.new(1,0.7,1)
	
	local LeftHandWeld = Instance.new("Weld", plr.Character["Left Arm"])
	LeftHandWeld.Part0 = plr.Character["Left Arm"]
	LeftHandWeld.Part1 = LeftHand
	LeftHandWeld.C1 = CFrame.new(0,1,0)
	
	local RightHand = Instance.new("Part", plr.Character["Right Arm"])
	RightHand.Name = "RightHandHitBox"
	RightHand.Transparency = 1
	RightHand.Size = Vector3.new(1,0.7,1)
	
	local RightHandWeld = Instance.new("Weld", plr.Character["Right Arm"])
	RightHandWeld.Part0 = plr.Character["Right Arm"]
	RightHandWeld.Part1 = RightHand
	RightHandWeld.C1 = CFrame.new(0,1,0)
	
end)

I am losing it on this lool

The .PlayerAdded function runs on server scripts only. You already have the player, which is the Player variable and you can also get the character by defining it like this:

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait() --if the character does not exist, it will yield the script until the character exists
1 Like

well how do i make it work in a local script? any other alternatives? cause i just want to fire it on one player and when he joins, thanks for the help btw
edit: i forgot to mention that the Case never spawns when player resets. how do i fix it? humanoid.died doesnt work :frowning:

You cannot make it work in a local script but you can place the script in StarterPlayerScripts and the script will run once the player joins.

I don’t know about what case you’re talking about though, seems like you didn’t provide me the full code.

(Sorry for the late reply, I kinda forgot about this thread and I for some reason did not get a notification when you replied.)

it’s fine. thanks for helping me out!

1 Like