Hello!
I am making a killer in which if you are touched by the killers hitbox, the killers humanoidrootpart CFrame will be the same as yours. The killer is a shadow-like figure (Using particle effects) so it is sort of “engulfing” the player (which is why I’m trying to make the CFrame be accurate to the players CFrame).
For some reason, it is inaccurate when running away from the killer. When you run away and the killer reaches you, it is off by a couple of studs.
If I stay still before it reaches me, it works perfectly fine.
I’ve tried playing around in the script by switching the CFrame around, adding "wait()"s to see if that helps, and such.
Here is the script:
local SCP017 = script.Parent.Parent.ShadowPerson
local Killsound = script.Parent.Kill
local Killsound2 = script.Parent.Kill2
local Killsound3 = script.Parent.Kill3
local Killsound4 = script.Parent.Kill4
local TargetBrick = script.Parent.Parent.TargetBrick
local Particle = script.Parent.Parent.ParticleBlock.ParticleEmitter
local VictimHide = script.Parent.Parent.VictimHide
local Attacking = false
function onTouch(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) and humanoid.Health > 0 and Attacking == false then
Attacking = true
local KillSoundRandomizer = math.random(1,4)
if KillSoundRandomizer == 1 then
humanoid.WalkSpeed = 0
humanoid.Parent.HumanoidRootPart.Anchored = true
wait(1)
local victimposition = humanoid.Parent.HumanoidRootPart.CFrame
Particle.Size = NumberSequence.new(1,7)
wait(.6)
SCP017.Parent.HumanoidRootPart.Anchored = true
Killsound:Play()
wait(.4)
SCP017.Parent.TargetBrick.CFrame = victimposition
VictimHide.Transparency = 0
wait(8)
humanoid.BreakJointsOnDeath = false
humanoid.Health = 0
VictimHide.Transparency = 1
Particle.Size = NumberSequence.new(7,1)
SCP017.WalkSpeed = 50
SCP017.Parent.HumanoidRootPart.Anchored = false
end
Attacking = false
end
end
script.Parent.Touched:connect(onTouch)
This happens because the player has network ownership of the character, which means the server experiences lag viewing properties of the character. I had the same problem with placing buildings on a vehicle while the player was driving it (gives them ownership). The solution is to use a RigidConstraint, which is guaranteed to be correct after one physics tick, since it tells the physics “these things are always attached with this constant offset”
it is because of the wait() lines. you are defining victim position a total of 1 second before you set the scp position to it, so if the player moves at all during that 1 second the scp will only move to the old position not the player’s new one. You can move the line where you define victim position so that its right before you set the scp position.
Okay, how would I go about forming the constraint through a script? And the attachments? Ive never used attachments or constraints in scripts before lol.
Attachments are just markers for where constraints can connect. Each attachment has a CFrame property, which unlike the CFrame of parts, is relative to the parent. In your case you just need to put an attachment at the default CFrame (you wont need to set it at all, then) on both the players torso and the enemy, then create a RigidConstraint whose Attachment0 and Attachment1 properties are set to these two attachments. The RigidConstraint should then be given the same parent as its Attachment0.
They stick but, I want the players humanoidrootpart to be completely accurate with the monsters humanoidrootpart. How would I achievethis? Rigidconstraint only sticks to the surface of things, and it seems like parts won’t collide if needed.