I had a problem.
First : I have an local script named Mmblox, which is an attempt to recreate graphics in minecraft. But working for death screen, I found out that the LoadCharacter function was not working. I tried neither many event types but neither worked. Can anybody sovle this?
Mmblox code:
--!nocheck
game.Players.LocalPlayer.CharacterAdded:Wait()
local path = game.ReplicatedStorage.block_graphics
local player = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
local eventres = script.eventres
local scriptres = script.scriptres
local res = script.res
local mat = require(script.scriptres.math)
do
tblock = mat.tblock
sawtooth = mat.sawtooth
end
local graphic_class = {}
local item_class = {}
local graph = {}
local terrain = {}
local MCEnum = require(script.scriptres.classes)
local x : EnumItem = {}
function graph:registerItem(name : string, id : string, tool : Tool)
local item = {}
item.ID = id
item.Name = name
item.Tool = tool
return item
end
type mc_itemObject = typeof(graph:registerItem(...))
function graph:registerBlock(regist_folder : {any}, name : string, id : string, mining_sound : Sound?,
drops : {mc_itemObject},
mining_sound_completed : Sound?,
renderdata : BasePart, destroyable : boolean,
custom_behavior : () -> ()
)
local block = {}
block.ID = id
block.mining_sound = mining_sound
block.drops = drops
block.mining_sound_completed = mining_sound_completed
block.render = renderdata
block.destroyable = destroyable
block.custom_behavior = custom_behavior
graphic_class[block.ID] = block
return block
end
type mc_blockObject = typeof(graph:registerBlock(...))
function graph:renderBlock(block : mc_blockObject , pos : Vector3)
local blockw = graphic_class[block.ID].render
if blockw then
local x : BasePart = block.render:Clone()
x.Parent = workspace
x.Position = pos
spawn(function()
local lastsize = x.Size
local clicked = false
local fx = game.ReplicatedStorage.data.select:Clone()
fx.Parent = x
fx.Adornee = x
fx.Visible = false
if block.destroyable then
local clickdetect = Instance.new("ClickDetector")
clickdetect.Parent = x
clickdetect.MouseClick:Connect(function()
clicked = true
x.CanCollide = false
x.Transparency = 1
for i,v in pairs(x:GetChildren()) do
v:Destroy()
end
local f = game.ReplicatedStorage.data.blockdestroy:Clone()
f.Parent = x
f:Emit(19)
wait(0.5)
x:Destroy()
end)
while wait() do
clickdetect.MouseHoverEnter:Connect(function(playerWhoHovered: Player)
if not clicked then
fx.Visible = true
end
end)
clickdetect.MouseHoverLeave:Connect(function(playerWhoHovered: Player)
if not clicked then
fx.Visible = false
end
end)
end
end
end)
spawn(block.custom_behavior)
return x
else
error("Failed to render block")
end
end
local deathcolor = Color3.fromRGB(255, 98, 98)
local h : Humanoid = player.Character:FindFirstChildOfClass("Humanoid")
h.Died:Connect(function()
local f = script.res.minecraft_death:Clone()
local n = f.youdied
f.Parent = player.PlayerGui
f.TextButton.TextTransparency = 1
f.TextLabel.Transparency = 1
f.youdied.TintColor = Color3.fromRGB(255, 255, 255)
game.TweenService:Create(f.youdied, TweenInfo.new(1), {TintColor = deathcolor}):Play()
game.TweenService:Create(cam, TweenInfo.new(1), {FieldOfView = 40}):Play()
f.youdied.Parent = game.Lighting
game.TweenService:Create(f.TextButton, TweenInfo.new(1), {Transparency = 0}):Play()
game.TweenService:Create(f.TextLabel, TweenInfo.new(1), {TextTransparency = 0}):Play()
wait(1)
f.TextButton.MouseButton1Click:Connect(function()
f:Destroy()
n:Destroy()
game.TweenService:Create(cam, TweenInfo.new(1), {FieldOfView = 70}):Play()
eventres:WaitForChild("Mm_Died"):Fire(player)
end)
end)
---------------------------------------------------------------------------------------------------------------------------
local blocks = {}
blocks.Grass = graph:registerBlock(graphic_class, "Grass", "001", nil, nil, nil, path["Grass (Snowed)"], true, function() end)
blocks.Dirt = graph:registerBlock(graphic_class, "Dirt", "002", nil, nil, nil, path["Dirt"], true, function() end)
blocks.Bedrock = graph:registerBlock(graphic_class, "Bedrock", "003", nil, nil, nil, path["Bedrock"], false, function() end)
blocks.Wood = graph:registerBlock(graphic_class, "Wood", "004", nil, nil, nil, path["Wood"], false, function() end)
---------------------------------------------------------------------------------------------------------------------------
terrain.buildings = {}
---------------------------------------------------------------------------------------------------------------------------
--> terrain, graph, mat
local __X = workspace.start.Position
local current = __X
workspace.start:Destroy()
for i = 0,15 do
for j = 0,15 do
graph:renderBlock(blocks.Grass, current + Vector3.new(tblock(i) , 0, tblock(j)))
end
end
current = Vector3.new(__X.X, current.Y, __X.Z)
current -= Vector3.new(0, 4, 0)
for a = 0,7 do
for i = 0,15 do
for j = 0,15 do
graph:renderBlock(blocks.Dirt, current + Vector3.new(tblock(i) , 0, tblock(j)))
end
end
current = Vector3.new(__X.X, current.Y, __X.Z)
current -= Vector3.new(0, 4, 0)
end
for i = 0,15 do
for j = 0,15 do
graph:renderBlock(blocks.Bedrock, current + Vector3.new(tblock(i) , 0, tblock(j)))
end
end
Mm_died script:
script.Parent.Parent.eventres:WaitForChild("Mm_Died").Event:Connect(function( player : Player)
print("OK")
player:LoadCharacter()
end)
And also remember Mmblox is localscript, the Mm_Died script is legacy.
I would be happy if anyone found the issue.