How to lock a player?

Hello,

So I am trying to lock the player cuz I am using a Btools which you can kill someone with but I found if I lock a part it can’t be moved. I am unsure on how I can lock the player though as it is a model not a part so people can just use btools to move the player or stretch it.

I was going to use this but as I said it only works on parts I think as I can’t see a properties called Locked in a model.

https://developer.roblox.com/en-us/api-reference/property/BasePart/Locked

2 Likes

try locking all the parts inside of their character

I was thinking about that I just did not know if it would be the most efficient way.

put jumppower and walkspeed to 0 and anchor one of the character part to don’t be pushed.

But I still want them to move lol. Don’t you know what lock means?

1 Like

Interesting question. Couldn’t you GetChildren() or GetDecendsants() of the player, and then lock those descendants/children?

You need to use a for loop on Model:GetDescendants(), I’ll show you what that looks like.
Usually player parts are locked by default, but I have noticed a few UGC items seem to not abide by this for whatever reason.

Once you figure out how to do this, you just need to implement a PlayerAdded correctly and your problem should be solved.

local Players = game:GetService("Players")

local function CharacterAdded(character)
	for _, part in ipairs(character:GetDescendants()) do
		if part:IsA("BasePart") then
			part.Locked = true
		end
	end
end

local function PlayerAdded(player)
	player.CharacterAdded:Connect(CharacterAdded) -- Lock player parts
	player.CharacterAppearanceLoaded:Connect(CharacterAdded) -- Lock any added accessories
	if player.Character then
		CharacterAdded(player.Character)
	end
end

Players.PlayerAdded:Connect(PlayerAdded)
for _, player in ipairs(Players:GetPlayers()) do
	coroutine.wrap(PlayerAdded)(player) -- Handle existing players
end
4 Likes

I’m not sure if I’m understanding what you mean correctly, but couldn’t you just change the code in the build tools to check if it is stretching a player’s character? Like does the BuildTool use raycasting or mouse.target?

1 Like