Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to shove a part inside a player so that i detect when it touches someone???

Asked by 4 years ago
Edited 4 years ago

How to have an invisible part inside the players? Do i put it in a specific category like starter pack or something? It needs to move along with the player like a hitbox or something

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

I'm not really an expert but you could use a morph system which when a new player joins it automatically morphs them so they have a part in their chest which is invisible like a hit box or just write a script so if a humanoid is detected touching a part with another humanoid it does what you want it to do

UPDATE:

This script should work to morph it onto the player

If you put a script with the code I provided below in serverscriptservice with the part you want inside in the script it should weld it to the players uppertorso if using R15. If using R6 just simply change the UpperTorso text to the part you want

local charAdded = function(char)
    local a = script:WaitForChild('hitbox'):Clone() -- Hitbox should be changed to whatever the part name is
    local w = Instance.new('Motor6D')
    w.Part0 = char:WaitForChild('UpperTorso') -- Change this to whatever part of the character you wish to weld it to
    w.Part1 = a
    w.Parent = char['UpperTorso'] -- This should be the same part as above
    a.Parent = char
end

game:GetService('Players').PlayerAdded:Connect(function(plr)
    if plr.Character then
        charAdded(plr.Character)
    end

    plr.CharacterAdded:Connect(charAdded)
end)
0
Awesome but where would i place the part with the script so that it moves with the player? Mast3rStRix 43 — 4y
0
I'd say place it in serverscriptservice,workspace or replicated storage. I ain't sure though. I guess it depends what you want it to do when the hitbox is detected kyloren528 11 — 4y
0
Right now i have it in a part in workspace where should it actually go so that it moves with the character (Im trying so hard to make sense I hope u understand what im talking about) Mast3rStRix 43 — 4y
0
Have you made it sort of morph to the character? kyloren528 11 — 4y
View all comments (36 more)
0
I dont know how to do that Ill search it Mast3rStRix 43 — 4y
0
You using r15 or r6? kyloren528 11 — 4y
0
r15 Mast3rStRix 43 — 4y
0
I have provided a script above for you kyloren528 11 — 4y
0
Thankss ill try it! Mast3rStRix 43 — 4y
0
What I suggest doing for the part is getting a R15 dummy and copying the uppertorso part and rename it and make it invisible for the morph and just place it in the script with a name like hitbox kyloren528 11 — 4y
0
great ill do that! Mast3rStRix 43 — 4y
0
Alright, Let me know if it works! kyloren528 11 — 4y
0
I put this script in serverscriptservice, put the part named "hitbox" inside the the script making the parent of 'hitbox' the script and when i run it spawns in the same location that i placed it at first and doesnt move on the character Mast3rStRix 43 — 4y
0
What am i doing wrong? Mast3rStRix 43 — 4y
0
Let me check it out now kyloren528 11 — 4y
0
Did you anchor the part? If so unanchor it kyloren528 11 — 4y
0
If it doesn't work upload the RBXL on here and I can take a look at the script. It all works on my end unsure why it isn't working kyloren528 11 — 4y
0
Its not anchored Mast3rStRix 43 — 4y
0
Thats the rblx. By the way thanks so much for being so helpful!!! Mast3rStRix 43 — 4y
0
I'll check the rbxl now kyloren528 11 — 4y
0
Here. You made the part too big it worked but the part was massive. Here is a fixed version of it now https://we.tl/t-REYz88egal kyloren528 11 — 4y
0
Oh lol Thanks for being so helpful, you are amazing!  Mast3rStRix 43 — 4y
0
Also is it supposed to not stick on the player and just stand there on the map? Mast3rStRix 43 — 4y
0
It should move around with the player kyloren528 11 — 4y
0
Alright Mast3rStRix 43 — 4y
0
What the hell is wrong with my character Mast3rStRix 43 — 4y
0
What happened? kyloren528 11 — 4y
0
The part doesnt stay like that it just stays in the map Mast3rStRix 43 — 4y
0
Hmm. Make sure you are on r15. Go to gamesettings > Avatar > Avatar Type > Make sure R15 has a blue circle. Make sure the script is in serverscriptservice kyloren528 11 — 4y
0
Its set to r15 Mast3rStRix 43 — 4y
0
I am unsure on why it isn't working. Could you send me a gif of it? kyloren528 11 — 4y
0
I have a screenshot http://pasteboard.co/Jg7NdoP.png im not on pc anymore sorry Mast3rStRix 43 — 4y
0
I am unsure why it isn't working. Could you try remove your package and test it then? kyloren528 11 — 4y
0
Can you please explain how to do that? Mast3rStRix 43 — 4y
0
If you go on your avatar and go to a basic block avatar. I want to see if that will work kyloren528 11 — 4y
0
It works with the basic square avatar!!! Awesome but that means it wont work for every player? Mast3rStRix 43 — 4y
0
Is there a way to make it work for every avatar?? Mast3rStRix 43 — 4y
0
I am trying to think why it only works for the square avatar. kyloren528 11 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

Yo Mast3r,

I would just use Weld Constraints to Weld the parts onto the character's body parts... That way you can have a bunch of hit boxes on different parts of the body part or even one part... For example, if you want a part to be welded to the UpperTorso and have a hitbox on there:

Server Script in ServerScriptService: Weld Part To Torso

local part; -- Initialize this to where ever the part is, it can be anywhere as long as it's not on the client (For FE Enabled reasons)
local players = game:GetService("Players");

players.PlayerAdded:Connect(function(plr)
    local char = plr.Character or plr.CharacterAdded:Wait();
    local u_torso = char:WaitForChild("UpperTorso");
    local new_weld = Instance.new("Weld Constraint");
    local new_part = part:Clone();
    new_part.Parent = u_torso;
    new_part.CFrame = u_torso.CFrame;
    new_weld.Parent = new_part;
    new_weld.Part0 = u_torso;
    new_weld.Part1 = new_part;
end)

That would weld the part to the character's upper torso and then you can detect collision with that part. Remember that my script places the part in the UpperTorso, so normal character detection won't work because the parent of the part isn't the character but instead the UpperTorso... You can change the parent if you want, this was just an illustration of WeldConstraints.

Hope I helped and have a wonderful day/night.

Thanks,

Best regards,

Idealist Developers

0
I put this script in serverscriptservice, put the part named "hitbox" inside the the script making the parent of 'hitbox' the script and when i run it spawns in the same location that i placed it at first and doesnt move on the character what am i doing wrong? Mast3rStRix 43 — 4y
0
Did you correctly initialize the part variable in the script to reference the "hitbox" part? IdealistDeveloper 234 — 4y
0
I got it to work but it only works with the default avatar the square one Could you help me understand why that happens?? Mast3rStRix 43 — 4y
0
It will only work with R15 avatars because I am referencing "UpperTorso" For R6 you need to reference "Torso" instead. However, if you want it to work with both, you can use the HumanoidRootPart and reference that instead. Then you can mess around with the CFrame based on where you want the part to be. IdealistDeveloper 234 — 4y
0
ok thank you ill try that Mast3rStRix 43 — 4y

Answer this question