How would i even start this?

Hello!

Im trying to create a TABS (Totally Accurate Battle Simulator) NPC placement system. I have no idea how to start this. The player would pick a npc from a ui, click to place on a certain point on the map. Any help is very appreciate as im very much struggling because my scripting skills are insanely low.

You can use Model:MoveTo(Position or CFrame) to move your NPC.
And local mouse = player:GetMouse() then Model:MoveTo(mouse.Hit.p).

You have to use remotes for this by the way

1 Like

Well, first you could detect when the player clicks the gui. You could get the mouse position of the player, and when they click you could fire a remote which a script answers to, cloning the npc, placing it down at the position and then parenting it to workspace or a folder in workspace. The npcs could be in a folder in replicated storage, and they could get the specific npc by the button name they clicked matching the replicated storage child name.
This is just the layout, not the actual code (sorry)

1 Like

Also dont forget an anticheat and a datastore to save things, DataStore2 is quite easy to use so I suggest that
(I can help with the DataStore)

1 Like

Thank you i like this idea!

And, giving code is not really allowed anyway so, all good.

Edit: So you mean fire the client on the remote, which a script in maybe ServerScriptService answers,then clone npc put it at position. Correct?

1 Like

Im stuck on how to get the mouse position from a different script (the answering script) in ServerScriptService. Should i move the script some place else?

1 Like

Yes, I mean that, sorry for being a bit confusing.

when calling the remote event you can put the position in the parameters, and when the script listens get that value and make the position the position you sent. Example:

client:
placementEvent:FireServer(position_value_here)

server:
placementEvent.OnServerEvent:Connect(function(Player, position)

You can get the mouse position from the remoted fired to your ‘answering’ script

You mean like

Client

event:FireServer(MousePosition?)?

if so im still confused how to get the mouse position.

1 Like

yes, but you might need to make it like
position = CFrame.new(Mouse.Hit.Position.X, Mouse.Hit.Position.Y + npc.PrimaryPart.Size.Y / 2, Mouse.Hit.Position.Z)

So make sure the npc has a primary part

Edit: didn’t read that you were confused about the mouse position, whoops.
To get the mouse position you could do local Mouse = player:GetMouse()
Also when you’re coding, make sure to also do Mouse.TargetFilter = npc

1 Like

Where and how would i use Mouse.TargetFilter = npc? sorry for like tons of questions but my scripting skills are insanely low.

edit: i mean which script this would go in, but thank you for the information below.

1 Like

It’s alright don’t worry, I’m not a pro either lol

You can use it in a runservice.RenderStepped function, but I’m not hugely sure the main difference between heartbeat, renderstepped, and stepped so you may just want to do whatever works best. This is also where you should put all the values that would be changing (like position) so it updates.

oh, whoops (again), you would change all the values in the client until they click again, firing the remote and sending the values with it. So it would be in the local script. The thing the server script would do is just applying the values from the event and parenting it to a folder or workspace.

Also, there’s a way that uses OOP but I’m not too familiar with that, but there is a tutorial with that way if you want to check it out:
Creating A Furniture Placement System - Resources / Community Tutorials - DevForum | Roblox