Basically my character will take more than its max health, but the death sound doesnt play and the character wont respawn. Im not really sure what is going on. Ive removed the health script from the character so it doesnt regain health.
Whats supposed to happen is that when I press E, the character is supposed to turn into red bricks and then fall over. The player then respawns and a bricky clone of them is still there. However, the character doesnt respawn.
There is a LocalScript in PlayerGui that fires a RemoteEvent when the E key is pressed and a Script inside of ServerScriptService with the script below
Video:
ServerScriptService script:
game.ReplicatedStorage.Brick.OnServerEvent:Connect(function(plr)
if plr then
local char = plr.Character
for i,v in pairs(char:GetDescendants()) do
if v:IsA("Shirt") or v:IsA("Pants") then
v:Destroy()
end
if v:IsA("Motor6D") or v:IsA("Weld") then
local weld = Instance.new("WeldConstraint",v.Parent)
weld.Part0 = v.Part0
weld.Part1 = v.Part1
v:Destroy()
end
if v:IsA("MeshPart") or v:IsA("Part") then
v.CanCollide = true
v.Material = Enum.Material.Brick
v.Color = Color3.new(0.592157, 0, 0)
if v:FindFirstChild("SpecialMesh") then
v:FindFirstChild("SpecialMesh").Texture = nil
end
if v:IsA("MeshPart") then
v.TextureID = ""
end
end
if v.Name == "BodyColors" then
v:Destroy()
end
end
char.Humanoid.PlatformStand = true
char.HumanoidRootPart:Destroy()
char.Humanoid:TakeDamage(105)
wait(2)
char.Archivable = true
local clone = plr.Character:Clone()
char.Archivable = false
for i,v in pairs(clone:GetDescendants()) do
if v:IsA("MeshPart") or v:IsA("Part") then
v.CanCollide = true
v.Material = Enum.Material.Brick
v.Color = Color3.new(0.592157, 0, 0)
end
end
plr.CharacterAdded:Wait()
clone.Humanoid:Destroy()
clone.Parent = workspace
end
end)
Hi, there is a few flaws with your current script. Try this;
game.ReplicatedStorage.Brick.OnServerEvent:Connect(function(plr)
local char = plr.Character
if not char then return end
local humanoid = char:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid:GetState() == Enum.HumanoidStateType.PlatformStanding then return end
humanoid.PlatformStand = true
for i,v in pairs(char:GetDescendants()) do
if v:IsA("Shirt") or v:IsA("Pants") then
v:Destroy()
end
if v:IsA("Motor6D") or v:IsA("Weld") then
local weld = Instance.new("WeldConstraint",v.Parent)
weld.Part0 = v.Part0
weld.Part1 = v.Part1
v:Destroy()
end
if v:IsA("MeshPart") or v:IsA("Part") then
v.CanCollide = true
v.Material = Enum.Material.Brick
v.Color = Color3.new(0.592157, 0, 0)
if v:FindFirstChild("SpecialMesh") then
v:FindFirstChild("SpecialMesh").Texture = nil
end
if v:IsA("MeshPart") then
v.TextureID = ""
end
end
if v.Name == "BodyColors" then
v:Destroy()
end
end
for i,v in pairs(char:GetDescendants()) do
if v:IsA("MeshPart") or v:IsA("Part") then
v.CanCollide = true
v.Material = Enum.Material.Brick
v.Color = Color3.new(0.592157, 0, 0)
end
end
task.wait(2)
local FakeChar = Instance.new("Model")
FakeChar.Name = "Fake-"..plr.Name
for i,v in pairs(char:GetDescendants()) do
if v:IsA("MeshPart") or v:IsA("Part") then
local FakePart = v:Clone()
FakePart.Anchored = true
FakePart.Parent=FakeChar
end
end
plr:LoadCharacter()
FakeChar.Parent = workspace
end)
Be aware that the fake-character is no longer categorised as a character. It’s simply a model with all the corresponding parts the real character had.