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
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
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!