String attribute value is printing/being observed as Nil

i work on this train game that has a system where when you reach the end of a track, you can turn around to go the other way. it works for every other end of track except for just one. in order for the player to get the turn around prompt, the script must check if the train’s destination string value is the same as the turn around part’s destination string attribute value.

if it wasn’t obvious already, the destination string attribute value for some reason isn’t being seen as the value already set in studio, and comes up as Nil.

if anyone could explain why this could be happening, or needs a sample of the code to review what’s happening that’d be much appreciated

image

btw it’s also showing up as Fairvale in the attributes section on the server side too, so it can’t be that only the client has it

We will definitely need the code as we can’t really know why it’s nil

this is the part that actually does the stuff needed, the locals defined are functions except for player. this all works except for the touched.Parent:GetAttribute(“Station”) parts. anything below where that is called for, it breaks the script.

if table.find(allowed_blocks, touched.Name) then
					local train = find_train_sequence(touched)
					local carriage = FindCarriageModel(touched)
					local player = game.Players:FindFirstChild(train.CONFIG.Driver.Value)
					
					if carriage ~= nil then
						--[[train.CONFIG.SCRIPT.EVENT_Function:FireClient(player,"Train_Terminate", train.CONFIG.XP.RC_Earn.Value, carriage)
						player.RailCoins.Value += train.CONFIG.XP.RC_Earn.Value]]
						print(train.CONFIG.Destination.Value)
						print(touched.Parent:GetAttribute("Station"))
						if train.CONFIG.Destination.Value == touched.Parent:GetAttribute("Station") then
							print("f")
							train.CONFIG.SCRIPT.EVENT_Function:FireClient(player,"Train_Terminate", train.CONFIG.XP.RC_Earn.Value, carriage)
							player.RailCoins.Value += train.CONFIG.XP.RC_Earn.Value
						end
					end
			
				end

the reason why .Parent is there with touched is just how it is, the attribute is in a model, which the part firing the touched event is under.

issue has been resolved. no longer need assistance, replies need some amount of characters to be posted and i need to close so

If you solved the problem on your own, please reply to your original post with your solution and mark it as the solution, to assist anyone facing the same issue later on!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.