The SpawnReset script has had me try cloning the previous candle, and destroying the previous candle, making the previous the now current candle when you die (cycle repeats). I’ve also tried parenting it to StarterGear which lead to no avail, only sending the same message in the output. (without the SpawnReset script) I’ve tried tracking down the wax part of the candle, but it’s just absolutely gone. Whenever I try to teleport to it or above it, I just end up in the void.
It’s not the viewportframe that’s the problem, it’s the actual tool object that’s the problem. The wax in the actual tool is gone. Sorry should have specified that
That’s okay! Sorry for the late response, and thanks for clearing that up. I think it may be some sort of mismatch of the ViewportFrame with the Candle model in the backpack being deleted, cloned and reparented. Could I see how the candle looks like in the backpack (in the explorer) in-game, please? I’m not sure how much of it is in the viewport and how much is in the physical game.
Edit: I’m pretty sure it doesn’t have to do with any UI properties. I set up a really simple UI and reset; The viewport frame (and it’s children) were still there (UI’s ResetOnSpawn property was set to true). I may be wrong though.
There is no need to clone and destroy flashlight while in the backpack.
You can put the flashlight tool into the ServerStorage, and in server side clone it and put it in the player backpack each time the character spawn.
In client side, you only have to move the flashlight parent from backpack to character to equip and character to backpack to unequip, without cloning and destroying it at all, only changing parent.
Server Side
local PlayerService = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Flashlight = ServerStorage:WaitForChild("Flashlight")
local function SetupFlashlight(NewPlayer)
local Backpack = NewPlayer:WaitForChild("Backpack")
if Backpack then
Flashlight:Clone().Parent = Backpack
end
end
PlayerService.PlayerAdded:Connect(function(NewPlayer)
NewPlayer.CharacterAdded:Connect(function()
SetupFlashlight(NewPlayer)
end)
end)
Client Side
local PlayerService = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local Player = PlayerService.LocalPlayer
local Character = Player.Character
local Backpack = Player:WaitForChild("Backpack")
local Flashlight = Backpack and Backpack:WaitForChild("Flashlight")
local function UpdateBackpack()
Character = Player.Character
Backpack = Player:WaitForChild("Backpack")
Flashlight = Backpack and Backpack:WaitForChild("Flashlight")
end
local function SetupFlashlight()
if Backpack and Flashlight and Character and Flashlight.Parent == Backpack then
Flashlight.Parent = Character
elseif Backpack and Flashlight and Character and Flashlight.Parent == Character then
Flashlight.Parent = Backpack
end
end
Player.CharacterAdded:Connect(UpdateBackpack)
UserInputService.InputBegan:Connect(function(Input, Processed)
if Input.KeyCode == Enum.KeyCode.F and not Processed then
SetupFlashlight()
end
end)
Don’t worry!
I just remembered that, when you equip a tool, it’s Parent becomes the Player rather than the Backpack. What happens in your code is that your SpawnReset script defines the flashlight variable as an existing flashlight model within the Backpack, where it then tries to clone it after you respawn. The issue is that everything within a backpack is cleared upon death (and your code is trying to clone something that’s already cleared), so you’d either want to Clone the instance before the user dies and keep such clone as a reference (only to clone it again when it should be used), or follow @Crygen54’s advice.
The reason your error appeared, if I’m not mistaken, is because your code was trying to reference an Instance that had already been destroyed after death (and it’s Parent therefore being “NULL”).
Please let me know if you didn’t understand something. Hope this helps you!
Thank you so much for your persistent help! I probably would have given up if it weren’t for your first message that encouraged me that this could be solved, lol