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

Simple 8 line script isnt working? (CFraming and cloning)

if x >= 0 and x <= 100 then
		 game.Lighting.LMG:Clone().Name = "LMGClone"
		game.Lighting.LMGClone.Parent = game.Workspace
		game.Workspace.LMGClone.PrimaryPart = game.Workspace.LMGClone.Handle
		game.Workspace.LMGClone:SetPrimaryPartCFrame(script.Parent.CFrame)
		game.Workspace.LMGClone.Name = "LMG"
	end
end

Its supposed to take LMG from lighting, and put the entire LMG model in the location of script.Parent

script.Parent is just a part btw

4 comments

0

Not related to your question but the only things that should be stored in the Lighting Service are stuff like Sky or lighting effects. Anything else really should be stored in a storage service such as ReplicatedStorage or ServerStorage.

1

Does it give you an error message in the Output?

0

no message in output, please help :(

1 answer

you should really use a variable

if x >= 0 and x <= 100 then
         game.Lighting.LMG:Clone().Name = "LMGClone"--all you did here was clone it and rename it, its parent is still nil
        game.Lighting.LMGClone.Parent = game.Workspace -- there is not LMGClone in lighting as you renamed the CLONE
        game.Workspace.LMGClone.PrimaryPart = game.Workspace.LMGClone.Handle
        game.Workspace.LMGClone:SetPrimaryPartCFrame(script.Parent.CFrame)
        game.Workspace.LMGClone.Name = "LMG"
    end
end

it should look like

if x >= 0 and x <= 100 then
        local lmgclone = game.ServerStorage.LMG:Clone() -- you should not use Lighting for storage
        lmgclone.Parent = workspace
        lmgclone.PrimaryPart =workspace.LMGClone.Handle
        lmgclone:SetPrimaryPartCFrame(script.Parent.CFrame)
        lmgclone.Name = "LMG"
    end
end

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