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.
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
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?