Ad
Log in to vote
0

Car value not disconnecting?

Asked by 8 days ago
Edited 7 days ago

I'm trying to make a remote control car tool, it's supposed to do that when you unequip the tool, the car objectvalue is set to nil (nothing) and the "RemoteControlConnected" value in the car is supposed to be false. But for some reason, nothing happens. The "RemoteControlConnected" is not set to false and the ObjectValue is not set to nil, it's still set to the car? It's a serverscript inside an object value, parented to a tool. Why is this happening?

local value = script.Parent.VehConnected.Value
local tool = script.Parent

tool.Unequipped:Connect(function()
    if value ~= nil then
        print("Remote unequipped with vehicle connected, disconnecting...")
        for i,v in pairs(value:GetDescendants()) do
            pcall(function()
                if v.Name == "OwnerName" then
                    v.TextLabel.Text = "Not connected"
                end
            end)
        end
        value.RemoteControlConnected.Value = false
        wait(3)
        value = nil
    end
end)

1 answer

Log in to vote
1
Answered by 7 days ago
Edited 7 days ago

script.Parent.VehConnected.Value will give you a value not an object

so

local value = script.Parent.VehConnected.Value

Will actually set whatever Value is in VehConnected to the variable value, not the object itself

You might want to type

local value = script.Parent.VehConnected

Then line 05 would be

 if value.Value ~= nil then

And then in line 16 You type in

value.Value = nil
Ad

Answer this question