Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My hologram script isnt working? Error says nil value.

Asked by
Galicate 106
6 years ago

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

Log in to vote
0
Answered by
EgoMoose 802 Moderation Voter
6 years ago
Edited 6 years ago

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

More info here.

Ad
Log in to vote
0
Answered by 6 years ago

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)
0
After my line 9 but before the line 10 do plr.Character.Archivable = true satanxd666 60 — 6y

Answer this question