Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

UN - REMOVABLE Character?

So, i was trying to create some kind of " UN-REMOVABLE " character, which means DESTROYING the character won't effect it, which is... quite impossible? i tried cloning the player's character, making joints inside, moving it to player's character... but it didn't work EXAMPLE :

game.Players.LocalPlayer.Character.Archivable = true
local clone2 = game.Players.LocalPlayer.Character:Clone()
clone2.Parent = game.ReplicatedStorage
local actualclone = clone2:Clone()

game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function()
	if game.Players.LocalPlayer.Character == nil and game.Players.LocalPlayer.Character.Humanoid.Health == 0 then
	actualclone.Parent = workspace
	actualclone:SetPrimaryPartCFrame(CFrame.new(game.Players.LocalPlayer.Character))
	actualclone:MakeJoints()
end
end)

I fixed the errors as much as i could, i made the player's character Archivable, but i have a problem at changing the camera or keys.

--Thanks for reading.

2 comments

0

In line 10 make that makeJoints into MakeJoints. And don’t place your clones in Lighting, place them in ReplicatedStorage. Using Lighting as storage is deprecated.

0

Okay, but... that is not my problem right now, thanks for sharing your information.

3 answers

If you’re trying to make the character not respawn at death, don’t let it die. You can accomplish this by setting the Humanoid’s HumanoidStateType to Enum.HumanoidStateType.Dead. This disallows the death of a humanoid.

LocalScript:

local plr = game:GetService('Players').LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild('Humanoid')

hum:SetStateEnabled(Enum.HumanoidStateType.Dead, true)

On a side note, don’t put your clones or anything in Lighting, instead put them in ReplicatedStorage for client access, or ServerStorage for server access. Using Lighting as storage is deprecated, and just improper since Lighting is for our PostEffects and skyboxes.

1 comment

0

Sorry, i knew that, i also used that in an INFINITE loop, but it doesn't really work, and one more thing, i'm trying to make a clone of the character once it gets removed and move it to the fallen character parts ( dead state ) or when its joints are broken.

You cannot make a character which is immune to the effect of all weapons and scripts created by anyone.

However, inside the script for a weapon, in the part where it deals damage, you can make an exception for targets that meet certain requirements.

For example, let's say I made a sword, and I wanted everyone to TakeDamage from it except for me. A simple approach might look similar to this:

local sword = script.Parent
local hitbox = sword.Handle

local function swing(hit)
    local char = hit.Parent
    local player = players:GetPlayerFromCharacter(char)
    if player and player.Name ~= "amanda" then
        local human = char.Humanoid
        if human.Health > 0 then
            human:TakeDamage(25)
        end
    end
end

sword.Activated:Connect(function()
    --swingAnimation:Play()
    local bind = hitbox.Touched:Connect(swing)
    wait(.5)
    bind:Disconnect()
end

Please note that this does not fully demonstrate best practices regarding dealing damage and FilteringEnabled. It was quickly written to give you an idea of how to go about making exceptions for tools that deal damage.

Also note, you would most likely have a table full of UserIDs which you would check in order to make a whitelist.

In reality, there are many ways of achieving this, such as whitelist, special value objects stored in the character model, and it can be accomplished with small modifications to most any existing code.

3 comments

0

Uhm, Thanks for sharing your... " Valuable " information, but what i asked wasn't about humanoid's Health or " TakeDamage() ", Thank you for trying.

0

And one more thing, i'm trying to RESPAWN the player's character once its removed, which means cloning the character.

0

Hello. Because in your code snippet you checking when the Humanoid dies, it appears you are trying to reverse it. In reality, it is much easier to prevent it. How about instead of cloning the character, you just respawn them in the exact position they die? On died event, catch their HRP CFrame and then teleport them to that at spawn.

If you set your character to the new clone the keys will work and you can set workspace.CurrentCamera.CameraSubject to the clone's humanoid.

also heres a working version of what you needed

local plr = game:GetService'Players'.LocalPlayer
plr.Character.Archivable = true
local backup = plr.Character:Clone()
backup.Parent = game.ReplicatedStorage
removed = function()
plr.Character = backup:Clone()
workspace.CurrentCamera.CameraSubject = plr.Character.Humanoid
plr.Character.Parent = workspace
plr.Character:MakeJoints()
plr.Character.Humanoid.Died:connect(removed)
end
plr.Character.Humanoid.Died:connect(removed)
while wait() do
if plr.Character == nil then
removed()
elseif plr.Character.Parent ~= workspace then
removed()
elseif plr.Character.PrimaryPart ~= nil then
if plr.Character.PrimaryPart ~= nil then
backup.PrimaryPart.CFrame = plr.Character.PrimaryPart.CFrame
end
end
end

But what i did (in a script builder game) was put the character's parent to workspace.Camera since workspace.Camera is nil for the server and other clients. You also need to make a forcefield in your character. If you do this nobody else will be able to see your character. So you might want to make a clone that has the same position as your character. This will still be effected by Player:LoadCharacter() since that is impossible to be immune to.

2 comments

0

Err... what you are trying to say is... adding a forcefield to character?, or Loading the character at the same position/clone?

0

Sorry I worded that poorly. I just updated it and added a script that has the same idea as the one you made.

This discussion is preserved as it was. New answers, comments, and votes are closed.