Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

1 comment

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.

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.