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

How can you set a string value to nothing?? (Line 10)

Asked by 7 years ago
Edited 7 years ago

I've been trying to do this for quite a while now and still haven't figured out why it doesn't work!

I'm trying to set the String Value.value to nothing but it always gives me this in the output: 36: bad argument #3 to 'Value' (string expected, got nil)

Here's the script: (Line 10)

seat.ChildRemoved:connect(function(child2)
    if child2:IsA"Weld" and child2.Name == "SeatWeld" then
        game.Players[driver.Value].PlayerGui.VehicleUi:Destroy()
        if seat.Lights.Park == true then
            seat.MaxSpeed = 0
            seat.Lights.Park.Player = driver.Value
            vehicle.Parent = game.Players[driver.Value].Character
        else
            if seat.Lights.Park.Value == false then
                seat.Lights.Park.Player.Value = nil
                vehicle.Parent = game.Workspace
                for i = 40,0,-1 do
                    wait(1)
                    seat.Parent.CountDown.Number.Value = i
                    if i == 0 then
                        vehicle:Destroy()
                    end
                end
            end
        end
    end
end)
3
Just set the string value to an empty string: "". You can't set a string value to nil, it has to be a string type. Most value objects are like that, you need to pick a value to represent "nil" in your code. script_help 74 — 7y

1 answer

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

You can either do"" for an empty string or nil for it to lose its value completely. For a StringValue nil will give an error though.

Ad

Answer this question