How could I implement sanity checks on a tower placement system?

I am planning to create a placement system for my tower defense game. I’m just not sure how I would go about it? All I want to recieve from the client is a position in the workspace. I don’t care if it is a fake position as long as it is a possible position anybody could place it in. I am just not sure how to do this? I have considered creating a tiny part and using GetTouchingParts() but I am not sure that it’s the best method.

TL;DR

Register if a position in the workspace is a valid placement

Any help is appreciated. Thanks!

1 Like

Well if you have a mouse raycast then that’d be good cause then you could make a folder of placeable spawns and check if the MouseRay.Instance.Parent is equal to that folder

2 Likes

Thanks for the suggestion! How could I create a mouse raycast?

1 Like

i recommend this post

2 Likes

I’ll take a look at it. Thanks for the quick replies!

1 Like
Old Post

How could I process this information on the server? It seems like if I try to send this information over to the server they could still exploit it, or am I missing something here?

I found the solution. You need to send a player’s mouse position (via UserInputService:GetMouseLocation()) and a unitRay (workspace.CurrentCamera:ScreenPointToRay()). After that, the server casts a ray using all the parameters mentioned. Check if it is a valid ray, if it has an instance, and if it is a descendant of the placement part/folder.

You should also verify the origin of the ray on the server

1 Like

Ooh, you’re right. How could I verify the origin of it, though? I’d assume the server’d have to check but how would the server know if the origin is valid or not? :thinking:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.