C4 Mechanicsm Help

Hello! so i am wondering how would you make it so you have a tool and when you click it throws itself at your mouse point and stick to it and have the same orientation as the part it hit. Basically a sticky c4.

I’ve used roblox’s fake C4 gear and edited it but i still cant make it so it sticks to the hit position correctly and set its orientation, This is a video of me using my edited C4! robloxapp-20200826-1945147.wmv (1.9 MB) I’ve tried raycasting and im not really going with Rays and pretty new to it. This is the lua code, runned with client and yet to be server! LocalScript.lua (2.9 KB)

2 Likes

add mouse.Target to the throw part of the script then add a weld between mouse.Target and the C4

I see where your coming from, but i mean when the object hits something it sticks to it, i’ve got the go to the mouse target thing.

1 Like

mouse.Target is finding the object the mouse is pointing at so stick them together with a weld so it sticks to moving targets it also needs
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

Good point, but i still need help making it directly get the orientation of the hitting part simultaneously, like wherever the player is facing something like that.

Couldnt you make the C4 the handle and make the mesh face the back of the part so its the part the player holds so it faces them

Could you explain, by showing a example or some code?

Annotation 2020-08-26 201450
Name the C4 “Handle” and put it in the tool that throws it then change the orientation of the C4 mesh until it faces the back which you can see on the top right which has the GUI that shows which direction you are facing

Raycasting’s third variable Normal can help you with this.

I dont understand, what you mean. But i think i figured it out, by making a ray and shooting it by the lookvector and then getting the part it shot at’s orientation, but thanks for helping with this post i do appreciate it very much.

Its great you found a solution, I still don’t know *how to do stuff with rays

1 Like