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

Seat doesnt work when cloned to workspace from lighting?

Asked by
l_diue 30
4 years ago
Edited 4 years ago
comn = script.Parent
plr = game.Players.LocalPlayer
function onButton1Down(mouse)
    if game.Workspace:FindFirstChild(plr.Name.."s"..script.Parent.Name) then    
        game.Workspace[plr.Name.."s"..script.Parent.Name]:remove()  
        local model = game.Lighting.Animals[script.Parent.Name]:clone()                                      
        model.Parent = game.Workspace
        model.Name = plr.Name.."s"..script.Parent.Name
        model:MakeJoints()
        model:MoveTo(mouse.hit.p+Vector3.new(0,1,0))
        wait(0.3)
        comn.Unequipped:connect(Unequip)
        script.Parent:remove() -- removes the spawner tool
    else
        local model = game.Lighting.Animals[script.Parent.Name]:clone()                                      
        model.Parent = game.Workspace
        model.Name = plr.Name.."s"..script.Parent.Name
        model:MakeJoints()
        model:MoveTo(mouse.hit.p+Vector3.new(0,1,0))
        wait(0.3)
        comn.Unequipped:connect(Unequip)
        script.Parent:remove() -- removes the spawner tool
    end 
end

function onEquippedLocal(mouse)

    if mouse == nil then
        print("Mouse not found")
        return 
    end

    mouse.Icon = ""
    mouse.Button1Down:connect(function() onButton1Down(mouse) end)  
end


comn.Equipped:connect(onEquippedLocal)

Answer this question