What do you want to achieve? Keep it simple and clear!
Sow basically, I’m trying to make a housing system like adopt me, where it teleports you to a players house. In my case, I would check who the owner is, and spawn the house in workspace for only the client that wants to visit the house to minimize lag. Keep in mind, I already have a house system, i just need to spawn the interior. I also have a pre-built house.
What is the issue? Include screenshots / videos if possible!
I honestly have no clue on how to do this and where to add the scripts.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have looked pretty much everywhere, there’s no clear tutorial on how to do this.
Here’s my code that I tried in a server script
local prompt = script.Parent.GoInside
local owner = script.Parent.Owner
prompt.Triggered:Connect(function(playerWhoTriggered)
local character = playerWhoTriggered.Character
character:MoveTo(Vector3.new(game.Workspace.owner.Value.."sHouseSpawn".Position))
end)
This doesn’t spawn anything, I just grouped the house exterior with the interior and teleported the player to their, but I wanna minimize lag like i’ve stated earlier.
The interior of a house would usually be bigger than the exterior, so you wouldn’t wanna put them in the same place. Nevertheless, you should put them in the middle of no where, then put the house in ReplicatedStorage, and use :FireClient() to spawn the house to workspace once you enter the house. Then use :FireServer() if you have anything in the house that you want to update their changes the server. That is one way to do it.
So I would trigger the prompt, then send a message to client telling it to spawn and teleport the player to the house? Kind of like this:
-- Server
local rs = game.ReplicatedStorage
local house = rs.HouseInterior
prompt.Triggered:Connect(function(player)
rs.HouseEntered:FireClient(player)
end)
-- Client (where would I place it?)
local rs = game.ReplicatedStorage
local house = rs.HouseInterior
house.Parent = workspace
Also, may I ask how you would tp the player?
How can I remove the house once the player left.
Wouldn’t that largely depend on the size (more specifically, the amount of instances which make up the model), a model with thousands of instances which needs to be replicated from the server to every client would be a lot more resource exhaustive than if the model was entirely client-side for a single client.