Hello, Currently I'm working on a shop tycoon which will allow the player to freely place most objects they buy. The shop system I have is fully working, and I'm still working on an inventory system. Everything is FE (obviously), but something is puzzling me.
How do I actually make the placement system?
I'm not asking for a full script (I doubt anyone would be willing to give me a full script anyway) but maybe a guide, or what I'd need to construct my own placement system using filtering enabled and all that mumbo jumbo. I've tried multiple things, such as MoveTo and others but nothing has been working. I would post the script I made to move objects, but I've since deleted it (my bad hehe). Any help appreciated.
Thanks.
Hi,
I'm assuming you mean something along the lines of click on an area when buying then the model goes to that placement? In the server side, your remote event will require at minimum the location that the player desires to place it (in this case I will assume it's a mouse click). Side note, it's best to also check if the player can purchase the object on the server side to minimize exploit headaches.
The server side code can be run in any normal script in the workspace:
local RemoteEventFolder = game.ReplicatedStorage.RemoteEvents --wherever you store your remote events local PlacementEvent = Instance.new("RemoteEvent", RemoteEventFolder) PlacementEvent.Name = "PlacementEvent" local function onPlace(player, placement) --placement will be a vector3 that we get from the client local object = object_to_place --the new object you would like to place object:SetPrimaryPartCFrame(CFrame.new(placement)) end
The client side code can be run from any local script:
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local PlacementEvent = game.ReplicatedStorage.RemoteEvents:WaitForChild("PlacementEvent") --same name as what you named your event in the serverside code, and in the same folder that you placed it in mouse.Button1Down:connect(function() --fire the event when clicking down, but this can execute anywhere you want as long as you have a position to give it local position = mouse.Hit PlacementEvent:FireServer(position) end