Help With Script

What do I want to achieve?
I want to make the name of the tram model, Tram(Player Name Here) so I can Identify who has each tram. Example TramPizzaisrealyAWSOME

What is the issue?
The code I have used to do this doesn’t work.

Code

function Name()
	script.Parent.Name = "Tram".. Name.name
end

script.Parent.One.VehicleSeat.ChildAdded:Connect(Name)

Explorer
Coming Soon! - Tram Driving Simulator - Roblox Studio 11_10_2022 12_11_34 PM

Note: The Tram model is in ServerStorage and it gets cloned into the Workspace when a player presses a button.

function Name()
  local humanoid = script.Parent.One.VehicleSeat.Occupant
  if not humanoid then return end
  script.Parent.Name = "Tram"..humanoid.Parent.Name
end

script.Parent.One.VehicleSeat.ChildAdded:Connect(Name)
3 Likes

How would I find the tram? The section of my script below doesn’t work so how would I find the tram in the workspace?

workspace.Tram..Player

if you are on the client in a local script you would do…

workspace:FindFirstChild("Tram"..game.Players.LocalPlayer.Name)

if this is somehow on a server script, and you have a variable with the player needing the tram, you would

workspace:FindFirstChild("Tram"..Player.Name)
1 Like