'Unable to assign property Value. string expected, got nil'

  1. What do you want to achieve?
    I want the text from a stringvalue to turn to nil when intended (will be highlighted with **) and for the rest of the script to carry on.

  2. What is the issue?
    I am looking to remove the text from a stringvalue and set it to nil, I did not write the script, my scripter did, but due to timezone difference he cannot continue with it, and the deadline for the game jam is closing in

  3. What solutions have you tried so far?
    Dev forum, and my own prior scripting knowledge

Script
local RS = game:GetService("ReplicatedStorage")
local BindEventsFolder = RS:WaitForChild("BindEvents")
local RemoteEventsFolder = RS:WaitForChild("RemoteEvents")
local GameValuesFolder = RS:WaitForChild("GameValues")

local RoundStartBindEvent = BindEventsFolder:WaitForChild("RoundStart")
local RoundEndBindEvent = BindEventsFolder:WaitForChild("RoundEnd")

local PlayerTurnRemoteEvent = RemoteEventsFolder:WaitForChild("PlayerTurn")
local PlayerWordRemoteEvent = RemoteEventsFolder:WaitForChild("PlayerWord")
local RoundStartRemoteEvent = RemoteEventsFolder:WaitForChild("RoundStart")

local PhraseString = GameValuesFolder:WaitForChild("PhraseString")
local PlayerTurn = GameValuesFolder:WaitForChild("PlayerTurn")

local CurrentPlayersFolder = workspace:WaitForChild("CurrentPlayers")
local SeatedPlayers = CurrentPlayersFolder:WaitForChild("SeatedPlayers")

local Characters = workspace:WaitForChild("CurrentPlayers"):WaitForChild("SeatedPlayers")
local chairs = workspace:WaitForChild("Seats"):GetChildren()

RoundEndBindEvent.Event:Connect(function()
    PlayerTurn.Value = nil
	
	 **PhraseString.Value = nil**
	
	GameValuesFolder:WaitForChild("RoundStarted").Value = false
	for i, v in pairs(Characters:GetChildren()) do
		repeat task.wait() v.Parent = workspace until v.Parent == workspace
	end
	
	for i, character in pairs(CurrentPlayersFolder.UnseatedPlayers:GetChildren()) do
		print(0)
		--player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		--character:WaitForChild("ForceField"):Destroy()
		task.wait()

		for i, chair in ipairs(chairs) do
			local seat = chair.Seat
			print(1)
			if not seat.Occupant then
				seat:FindFirstChild("SeatWeld"):Destroy()
				print("unsitted")
				repeat task.wait() character.Parent = CurrentPlayersFolder.SeatedPlayers until character.Parent == CurrentPlayersFolder.SeatedPlayers
				break
			end
		end
		--end)
	end
end)

Can anyone help me, the only issue I get in the output is ‘Unable to assign property Value. string expected, got nil’, I dont know what it ‘expected’, and need some help ASAP

1 Like

I think the error message is quite self explanatory, the instance expects a string as value but you gave it nil.

I understand why you want this to be nil but it just won’t work with this value object.

Even by default if you try to print the value of a StringValue, you’ll see it prints a whitespace.

2 Likes

As binarystream mentioned, I am pretty sure you cannot set a StringValue to nil. As an alternative, you could set it to "" which is basically nothing as well.

StringValue.Value = ""
1 Like

You can also set it to “nil” as a string if you would like to… the concept of StringValue would be useless if you can cast any type on it.

1 Like

= nil is command to delete value.

1 Like

Alright, thanks for the reply. Hopefully we find another way to delete the text from the stringvalue.

1 Like

We tried this, but it gets really buggy, we needed the game to go in rounds, if that makes sense. For example, after the first round, the text from the stringvalue would be wiped for the next round.

1 Like

Yeah we need to delete the text from the stringvalue