#Refresh a Gui after player death
23 messages · Page 1 of 1 (latest)
You should show the scripts and the explorer
Oh sorry 2sec
@umbral glen
** You are now Level 5! **
local viewport = script.Parent
local char = game:GetService("Players").LocalPlayer.Character
local cam = Instance.new("Camera",viewport)
game:GetService("RunService").RenderStepped:Connect(function()
for i,v in pairs(viewport.Character1:GetDescendants()) do
v:Destroy()
end
for i,v in pairs(char:GetChildren()) do
local v2 = v:Clone()
if v2:IsA("Script") or v2:IsA("LocalScript") or v2:IsA("ModuleScript") or v2:IsA("Sound") then
v2:Destroy()
else
v2.Parent = viewport.Character1
if v2:IsA("Humanoid") then
v2.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
end
end
end
viewport.CurrentCamera = cam
cam.CFrame = game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5) * CFrame.Angles(0,math.rad(180),0)
in a localscript
@narrow monolith try listening to the player.CharacterRemoving event, it shows nothing because the character gets deleted and a new one gets created, on death.
is there a way to fix this in a 3-4 lines (im a beginniner in lua)
@narrow monolith is the character in the viewport the player or not?
Then try adding your code in a listener for player.CharacterRemoving.
You basically do:
game:GetService("Players").LocalPlayer.CharacterAdded:Connect(function(character)
— Your code
end```
You also don’t need to define a char variable as it is provided by the connection/listener.
Okay thx trying this tomorrow
game:GetService("Players").LocalPlayer.CharacterAdded:Connect(function(character)
local viewport = script.Parent
local char = game:GetService("Players").LocalPlayer.Character
local cam = Instance.new("Camera",viewport)
game:GetService("RunService").RenderStepped:Connect(function()
for i,v in pairs(viewport.Character1:GetDescendants()) do
v:Destroy()
end
for i,v in pairs(char:GetChildren()) do
local v2 = v:Clone()
if v2:IsA("Script") or v2:IsA("LocalScript") or v2:IsA("ModuleScript") or v2:IsA("Sound") then
v2:Destroy()
else
v2.Parent = viewport.Character1
if v2:IsA("Humanoid") then
v2.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
end
end
end
viewport.CurrentCamera = cam
cam.CFrame = game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5) * CFrame.Angles(0,math.rad(180),0)
end)
end)
thx this work but only when the player die
how can i fix this?
(The gui is on when the player join)
thx this work but only when the player die
When does it not work?
@narrow monolith
My gui is visible when a player join (start menu) but there nothing in the viewportframe untill the player die
Is the character loaded in, when your start menu is shown?
(And sorry if my english is a bit bad, tell me if u need me to explain something)
yes
@narrow monolith are you sure that your cam CFrame is correct?