Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with making some sort of item placement system?

Asked by
o_Blyzo 12
7 years ago

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.

0
This dude Tunicus made some pretty legit placement systems. You should try them out. https://www.roblox.com/games/1119327686/Placement-Demo-V2-testing Nikkulaos 229 — 7y

1 answer

Log in to vote
0
Answered by
mraznboy1 194
7 years ago

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
Ad

Answer this question