why is this working on my old roblox world but giving me errors on my new one?
local player = game.Players.LocalPlayer
local tool = script.Parent
local db = true
local newClone = nil
-- Get the current character safely and wait if not loaded
local function getCharacter()
local character = player.Character
if character and character.Parent then
return character
end
return player.CharacterAdded:Wait()
end
local function createGhostClone()
local char = getCharacter()
if not char or not char:IsDescendantOf(workspace) then
warn("Character is not valid or not in workspace")
return
end
if not db then return end
-- Clone character
newClone = char:Clone()
wait(1.5)
newClone.Parent = workspace -- Put clone somewhere visible but not under character
end
00:08:56.848 Players.xnite77.Backpack.Poop.LocalScript:31: attempt to index nil with 'Parent' - Client - LocalScript:31
00:08:56.849 Stack Begin - Studio
00:08:56.849 Script 'Workspace.xnite77.Poop.LocalScript', Line 31 - function createGhostClone - Studio - LocalScript:31
00:08:56.849 Stack End - Studio
Anyway, ill try to clean your code up and add some debugging, let me know what the code returns.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharaterAdded:Wait()
local tool = script.Parent
local db = true
local newClone
local function createGhostClone()
if not character then
warn("Character is not valid or not in workspace")
return
end
print("Character found")
if not db then return end
print("Debounce passed")
newClone.Archivable = true
newClone = character:Clone()
newClone.Archivable = false
print("new clone: "..newClone)
task.wait(1.5)
newClone.Parent = workspace
print("Finished")
end
Let me know what the print statements return, also your debounce seems to do nothing, thats why it might not be working.
Also this seems like very old code, its not up to todays standards.
I suggest you rework the whole thing or update the code.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local tool = script.Parent
local db = true
local newClone
local function createGhostClone()
if not character then
warn("Character is not valid or not in workspace")
return
end
print("Character found")
if not db then return end
print("Debounce passed")
newClone.Archivable = true
newClone = character:Clone()
newClone.Archivable = false
print("new clone: "..newClone)
task.wait(1.5)
newClone.Parent = workspace
print("Finished")
end
tool.Equipped:Connect(createGhostClone)
00:44:13.479 Players.xnite77.Backpack.Poop.LocalScript:18: attempt to index nil with 'Archivable' - Client - LocalScript:18
00:44:13.479 Stack Begin - Studio
00:44:13.479 Script 'Workspace.xnite77.Poop.LocalScript', Line 18 - function createGhostClone - Studio - LocalScript:18
00:44:13.480 Stack End - Studio
is my studio broken or smth??
i’ve never encountered such a problem its rly confusing
its been a while since ive used roblox studio but have smth changed? this is really strange, my old world works fine except some r15 animations dont seem to work anymore