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

ObjectValue is not a valid member of script?

Asked by 7 years ago

This script below works as intended. It disables the scripts in the game until all children are dispersed to their class, then enables them.

--Searches for all disabled scripts inside folder
local scripts = {}
function recursiveScriptSearch(inst)
    for _,v in pairs(inst:children()) do
        if v:IsA("Script") and v.Disabled then
            table.insert(scripts,v)
        end
        recursiveScriptSearch(v)
    end
end
recursiveScriptSearch(script.Parent)

for n,o in pairs(script.Parent.ReplicatedStorage:GetChildren()) do
    o.Parent = game.ReplicatedStorage
end
for n,o in pairs(script.Parent.Workspace:GetChildren()) do
    o.Parent = game.Workspace
end
for n,o in pairs(script.Parent.StarterGui:GetChildren()) do
    o.Parent = game.StarterGui
end
for n,o in pairs(script.Parent.StarterPack:GetChildren()) do
    o.Parent = game.StarterPack
end
for n,o in pairs(script.Parent.ServerStorage:GetChildren()) do
    o.Parent = game.ServerStorage
end
for n,o in pairs(script.Parent.ReplicatedFirst:GetChildren()) do
    o.Parent = game.ReplicatedFirst
end
for n,o in pairs(script.Parent.StarterPlayerScripts:GetChildren()) do
    o.Parent = game.StarterPlayer.StarterPlayerScripts
end
for n,o in pairs(script.Parent.StarterCharacterScripts:GetChildren()) do
    o.Parent = game.StarterPlayer.StarterCharacterScripts
end

for n,o in pairs(script.Parent.ServerScriptService:GetChildren()) do
    o.Parent = game.ServerScriptService
end
for n,o in pairs(script.Parent.Lighting:GetChildren()) do
    o.Parent = game.Lighting
end

--Go through all scripts and enable them
for _,v in pairs(scripts) do
    v.Disabled = false
end

print('Assets Loaded')
for n,o in pairs(game.Players:GetChildren()) do
game["Teleport Service"]:TeleportToPlaceInstance(game.PlaceId,game.JobId,o)
end


script.Parent:Destroy()

But I'm still getting errors like "ObjectValue is not a valid member of script." This error didn't not exist when I removed the code which enables/disables scripts. This is the code that gives an error.

wait(.1)
local fakeRope = Instance.new("Part")
fakeRope.Parent = game.Workspace
fakeRope.CanCollide = false
fakeRope.Anchored = true
fakeRope.Material = Enum.Material.DiamondPlate
fakeRope.BrickColor = BrickColor.new("Institutional white")
local val = script.ObjectValue.Value
local part1 = script.ObjectValue2.Value
local AttachPoint1 = val.Attachment
local AttachPoint2 = part1.Attachment
game:GetService('RunService').Heartbeat:connect(function()
    if val == nil or part1 == nil then script:Destroy() end
    local Pos1 = val.CFrame:toWorldSpace(CFrame.new(AttachPoint1.Position))
    local Pos2 = part1.CFrame:toWorldSpace(CFrame.new(AttachPoint2.Position))
    Pos1 = Vector3.new(Pos1.X,Pos1.Y,Pos1.Z)
    Pos2 = Vector3.new(Pos2.X,Pos2.Y,Pos2.Z)
    local Distance = (Pos1 - Pos2).magnitude
    fakeRope.Size = Vector3.new(0,0,Distance)
    --fakeRope.CFrame = part1.CFrame:lerp(val.CFrame,.5)
    fakeRope.CFrame = CFrame.new(Pos1, Pos2) * CFrame.new(0, 0, -Distance/2)
end)

I also get this error which didn't exist before "ServerScriptService.DevProductHandler.HealthScript:4: attempt to index local 'play' (a nil value)"

local play = game.Players:FindFirstChild(script.PlayerName.Value)
--if play == nil then script.Destroy() end

play.CharacterAdded:connect(function(Char)
wait(1)
Char.Humanoid.MaxHealth = Char.Humanoid.MaxHealth + script.Amount.Value
Char.Humanoid.Health = Char.Humanoid.Health + script.Amount.Value
Char.Humanoid.HealthDisplayDistance = 0
Char.Humanoid.NameDisplayDistance = 0
end)

game.Players.PlayerRemoving:connect(function(player)
    if player == play then script:Destroy() end
end)

Any idea on what I can fix in the first script that I wrote that would solve these errors?

1 answer

Log in to vote
0
Answered by 7 years ago
for i,v in next, script.Parent:GetChildren() do
    for l,n in next, v:GetChildren() do
        n.Parent = game[v.Name]
    end
end

use this instead of a bunch of loops. The startercharacterscripts might need a special one, but for the others its more efficient to do this

Are you sure that the script has ObjectValue in it? What type of script is the rope script, and where is it parented?

Ad

Answer this question