Destroying weld / setting parent to nil, kills the player

the title says it all

local humanoid = workspace:WaitForChild("alinaln").Humanoid
local Holding_WalkAnim = humanoid:LoadAnimation(workspace.Walk_Carry)
local BoxRE = game.ReplicatedStorage.BoxRE
local weldRightArm
local isBoxWeldSpawned = false
local rs = game:GetService("RunService")
local UIS = game:GetService("UserInputService")

	local hrp = workspace:WaitForChild("alinaln").HumanoidRootPart
	local Box = workspace.Box
	weldRightArm ="WeldConstraint")
	weldRightArm.Name = "RightArmWeld"
	Box.CFrame = hrp.CFrame *,0,-2)
	weldRightArm.Part1 = Box
	weldRightArm.Part0 = hrp
	weldRightArm.Parent = workspace
	isBoxWeldSpawned = true

	weldRightArm.Parent = nil
1 Like

First of all, your second event connection doesn’t check the weld at all. An exploiter could easily fire that event with anything they wanted to remove it (assuming the following was corrected). Secondly, your first argument is for a weld, but, it won’t be a weld, it will be the player who fired the remote. I’m not sure the reason they die to be honest.

Lastly, you are getting your character (and waiting for them in the workspace, instead you should really use somePlayer.Character) rather than the player who fired the remote’s character, which, I’m not really sure what you’re doing here exactly.

why is it better to use .character?, also yea i should add a check

also for some reason if i dont pass the weld as an argument, the weld gets set to nil

i just figured it out, the player dies bcuz i am passing the weld as an argument, but as you said it actually gets passed as the plr so im basically just setting the player to nil… big stupid

Its better to use .Character in case there is someone named, for example, “Baseplate.” They would get a character named Baseplate, but, there would also be the Baseplate part, and, it might conflict and pick the Baseplate instead of their character.

And, that’s not that stupid, I did that plenty when remotes were introduced into the game haha. :smile:

mk thats some good knowledge, thanks for the help!