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.
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)
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?
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:
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
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.