Deleting the clicked person's character file

I want to write code that can delete the model or player when I click f button

but i don’t know how

What do you mean? I don’t understand what you are trying to say by deleting the model or player.

I want to delete the target person’s character file by assigning a key

Please refer to the Dev API before making a post:

So how to delete the character file or model

Excuse me, you are not allowed to ask for code, you may only ask for an idea, or ask for people to help you out with a script you are already writing but has bugged or you are clueless.

Here are some things you should touch up on.

Put a RemoteEvent into ReplicatedStorage and name it DeleteChar.

Put this LocalScript into StarterGui:

--var
local uis = game:GetService("UserInputService")
local re = game.ReplicatedStorage:WaitForChild("DeleteChar")

--deb
local isActive = false

--func
uis.InputBegan:Connect(function(in)
    if in.KeyCode == Enum.KeyCode.F and isActive == false then
        isActive = true
        re:FireServer()
        wait()
        isActive = false
    end
end)

Put this Regular Script into ServerScriptService:

--var
local re = game.ReplicatedStorage:WaitForChild("DeleteChar")

--deb
local isActive = false

--func
re.OnServerEvent:Connect(function(plr)
    local char = workspace:FindFirstChild(plr.Name)
    char:Destroy()
end)

Note. This will make the player unable to respawn. If you want the character be able to respawn, replace:

char:Destroy()

with:

char.Humanoid.Health = 0

also, please do not ask for full scripts next time. I understand that this is your first time (judging by your profile age) though.

a

I replaced the part that says “in” with “a”

solved

1 Like