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

unable to set a beam's attachment1 to a referenced object in an objectvalue?

Asked by 5 years ago
local tool = script.Parent.Parent
local range = script.Parent.Parent.Range
local connectorpart1 = script.Parent.Parent.TrailPoint1
local beam = connectorpart1.Beam


tool.Activated:Connect(function()
    local orb = script.Parent.Parent.Range.Orb
    if orb.Value ~= nil then
        beam.Attachment1 = orb.Value
    elseif orb.Value == nil then
        beam.Attachment1 = nil
    end
end)


tool.Deactivated:Connect(function()
    local orb = script.Parent.Parent.Range.Orb
        if orb.Value ~= nil or orb.Value == nil then
            beam.Attachment1 = nil
        end
end)

this is a normal script inside a tool's handle.

when activated, the tool checks the object value to see if its value exists, then changes the beams attachment1 to the objectvalue's value. when deactivated it sets the attachment1 to nil.

the script throws an error stating: bad cast

0
is the property "value" of range a number or an object? User#23252 26 — 5y
0
range is an object. it contains the objectvalue. mantorok4866 201 — 5y

Answer this question