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

_____ is not a valid member of Model... what the heck?

Asked by 6 years ago

MY code:

sword = game.Lighting.ClassicSword
debounce = false
local function onTouch(Object)
    if (debounce ~= false) then return end
    debounce = true     
    local char = Object.Parent:FindFirstChild("Humanoid")
        if (char ~= nil) then
            local play = game.Players:GetPlayerFromCharacter(Object.Parent)
            if (play ~= nil) then

                game.Workspace.stairswplat.capsule = game.Lighting
                game.Lighting.opencapsule = game.Workspace
                local swordc = sword:Clone()
                swordc = play.Backpack
                wait(1)
                game.Lighting.capsule = game.Workspace
                game.Workspace.stairswplat.opencapsule = game.Lighting
                wait(.5)


            end 
        end
        debounce = false
end

script.Parent.Touched:connect(onTouch)

As you know, the Lighting folder is basically a store pile for things that aren't in the game. This script... I want it to exchange the capsule with the opencapsule through the Lighting folder. When you touch the model, specifically the middle of the capsule where the script is placed, the capsule model is exchanged with the opencapsule, and a sword is inserted into the player's backpack also from the lighting folder. But the error is "capsule is not a valid member of Model". None of my models are named Model. Help!

1 answer

Log in to vote
0
Answered by 6 years ago

The error message is telling you that the variable is of type "Model", not that it's named "Model". On line 11+, you're not allowed to do whatever it is you're trying to do. I think you mean to change the parent of each object, ex game.Workspace.stairswplat.capsule.Parent = game.Lighting (same idea on lines 12, 14, 16, and 17)

Stylistic notes:

  • Lighting is no longer recommended as the place to store items. Use ReplicatedStorage instead.
  • Your extra indent on lines 7 - 23 should not be there (highlight just those lines and press shift+tab to fix)
  • You don't need those parentheses on line 4, 7, or 9. In Lua, you can just do, for instance, if debounce ~= false then return end (you can also do if debounce then return end, in this case). Similarly, for line 7 you can just say if char then -- in Lua, any value that isn't false or nil is considered true in boolean logic.
Ad

Answer this question