Alright I'm a bit stuck in the making of my game. If you want to have a look at this game so far here is the link:
Ok so if you've checked out the game you'll notice whilst driving the car if you hit another car nothing happens. This is obviously the next step of my game development and I'm stuck as to how I can do this. The little white squares I have purposefully left visible around the side and front of the cars are what I call 'hitsensors'. Supposedly what happens is when they hit a car they will change a variable causing another script to activate etc... But I just do not know how to make the hitsensor.. sense!
I was told use magnitude, but as you can see that would be very difficult, impractical and time consuming and knowing me it wouldn't work. Currently they have script.Parent.Touched:connect(function) in them but since my cars teleport about and do not gain velocity apparently it is not activating the touched?
How can I do this? Thanks!
P.S The whole game is local.
Interesting problem you are having there. Unfortunately, there really is no way to detect when the car hits another car. Using touched events (if it worked) would be very inefficient and using magnitude would also be inefficient. The best way to go upon doing this, and you're probably not going to like this at all, is to restart using body objects like BodyVelocity and BodyGyro.
For one, your game will run faster by using body objects and the issue you are currently facing will resolve itself, since your cars will automatically apply to Roblox physics. BodyVelocity is to be used to move your vehicle straight and right/left while the BodyGyro is to be used to keep your vehicle straight and inline (that is, if I remember what BodyGyro does correctly- sorry, I'm rusty!)
I also recommend that you take the time to look at the other body objects, mainly BodyPosition.
Hope this helps and good luck with your game.
HitSensor.Touched:connect(function(hit) DoStuff() end)
Make sure you put this script where the parts of the car are located.
for Index,Part in pairs(script.Parent:GetChildren()) do if Part:IsA("Part") then Part.Touched:connect(function(Hit) if not Hit.Parent:FindFirstChild("Humanoid") then Part:BreakJoints() end end end) end end