One of my values returning "is"?

Hey Folks, I’m working on a vehicle spawning system and I have a check that checks a StringValue named SelectedItem and it is set to nil. However, in one of the if statements checking if this value isn’t value, it passes through (meaning it’s not nil) and in the server-side of my RemoteFunction, it’s returning the value “is”. Any solutions?

Photos/Code

		local check = false
		if selectedItem.Value ~= nil then
			check = intiatePurchase:InvokeServer(selectedItem.Value)
		else
			warn('No Vehicle Selected!')
		end

If statement checking if value is nil or not.

	local priceOfVehicle = shopAssets[vehicleName].VehicleSettings.CreditsRequired.Value
	if player.leaderstats.Credits.Value >= priceOfVehicle then
		player.leaderstats.Credits.Value = player.leaderstats.Credits.Value - priceOfVehicle
		print(vehicleName .. 'spawned!')
		return true
	else
		return false
	end
end

Remote Function


SelectedItem StringValue


StringValue set to nil


Error (In Output)

Thanks for checking! :cowboy_hat_face:

Queued

1 Like

Note: If a vehicle is selected, the rest of the code works. But if this error occurs and you select an item, it breaks the entire code.

I think the error is saying that:
" " is not valid member… So we are talking about an empty string here

So instead of checking

if selectedItem.Value ~= nil then

Check this:

if selectedItem.Value ~= "" then

Alright thanks, I’ve realized what you said. Let me test is rq

@nuttela_for1me Still returning the same error sadly.

Oops, you’re correct, forgot to add the .Value at the end, thanks!

1 Like

Also you do realise if this value, for whatever reason returns nil it will pass, so do:

if selectedItem.Value and selectedItem.Value ~= '' then end

Hmm yes I think the only type of value in StringValue is a string and not nil.

Yes, but it is an additional check, never hurts to be careful