Hello, I am working on a tycoon game and slowly i am figuring out how the scripts work. I'm trying to get the player to teleport to their base once it is loaded in. the map i have has 9 locations that are in Workspace.properties
Each property model has an objectvalue called owner and base.
Workspace > Properties> Property> Owner Base Property> Owner Base Property> Owner Base Property> Owner Base Property> Owner Base
I know the property selection is working and when testing, the game updated the Owner object value with player1 or whatever my character name is.
For moving the player to the Base i have what is below. This is followed from models in the studio and things i have read. As you can imagine it does not work.
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:wait() for _, property in pairs(workspace.Properties:GetChildren()) do if property:FindFirstChild("base") and property.Owner.Value == player character:MoveTo(property.base.Position + Vector3.new(0, 20, 0))
On line 5, you will probably want to change that FindFirstChild to a WaitForChild, to make sure it is loaded in. On line 7, you will probably want to change this to a simple CFrame warp. Example:
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:wait() for _, property in pairs(workspace.Properties:GetChildren()) do if property:WaitForChild("base") and property.Owner.Value == player local rootPart = character:WaitForChild("HumanoidRootPart") rootPart.CFrame = CFrame.new(property.base.Position) * CFrame.new(0, 20, 0) end end
If this doesn't help you, I may not be able to get back to you.