Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My hologram script isnt working? Error says nil value.

The code is inside a local script.

Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local interval = 60
local inuse = false

mouse.KeyDown:connect(function(key)
	key = string.lower(key)
	if string.byte(key) == 113 and inuse == false then
		inuse = true
		print(Player.Name)
		script.Parent.Parent.Character:Clone().Parent = game.Workspace
		wait(interval)
		inuse = false
	end
end)

I get the error at script.Parent.Parent.Character:Clone().Parent = game.Workspace

2 answers

✓ Accepted answer

By default characters in Roblox have the property Archivable = false. Simply set it to true and that should fix your error.

More info here.

Stop using KeyDown to get user input for less errors. use UserInputService. For how long have you used ROBLOX studio and how long without using it? like 2 years? and please use the GetService method to get services, as indexing with (.) to get a service (game.Service) is NO guarantee.


local service = game:GetService(“UserInputService”)
local plr = game:GetService(“Players”).LocalPlayer
local interval = 60
local inUse = false

service.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.Q and inUse == false then
        inUse = true
        print(plr.Name)
        local clone = plr.Character:Clone()
        clone.Parent = game:GetService(“Workspace”)
        wait(interval)
        inUse = false
    end
end)

1 comment

0

After my line 9 but before the line 10 do plr.Character.Archivable = true

This discussion is preserved as it was. New answers, comments, and votes are closed.