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

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

Asked by 6 years ago
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

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. Troidit 253 — 6y
1
Does it give you an error message in the Output? GottaHaveAFunTime 218 — 6y
0
no message in output, please help :( SyndicateHalo 40 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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
Ad

Answer this question