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

Why is my CFrame part spawning over my character's head?

Asked by
rexpex 45
7 years ago

I made a script that teleports a brick to the player's torso, all is well until i go next to another part. When i go next to another part, my brick goes over my head or the part im next to.

replicatedstorage = game:GetService("ReplicatedStorage")
tool = script.Parent.Parent.Parent
Smite = replicatedstorage:FindFirstChild("RicoClass").Smite
baseAtk = 32
debounce = true
M = replicatedstorage:FindFirstChild("RicoClass").SmiteModel
shockwave = replicatedstorage:FindFirstChild("RicoClass").Shockwave

Smite.OnServerEvent:connect(function(player)
local root = player.Character:FindFirstChild("HumanoidRootPart")
local m = M:clone()
local smiteM = m:GetChildren()
local shockW = shockwave:clone()
local dmg = math.floor(script.Parent:FindFirstChild("Charging").Value / 1.6 + baseAtk + 0.5)
    print(script.Parent:FindFirstChild("Charging").Value)
wait()
    print("s")
--------------------------------------------------------
for i, v in pairs(smiteM) do -----Goes into a Model i made
    if v.Name == "Inner" then ----After going through the model, it gets looks like the model that is named "inner"
        v.CFrame = root.CFrame + Vector3.new(0,-5,0) ----My teleporter
        v.Parent = game.Workspace
        v.Rotation = Vector3.new(0,0,90)




for i = 0,3,0.5 do -----makes sure the brick teleports to my player's torso
wait(0.01)
  v.CFrame = root.CFrame + Vector3.new(0,-5,0)
v.Rotation = Vector3.new(0,0,90)
  v.Size = v.Size + Vector3.new(0,i,i)
  v.CFrame = root.CFrame + Vector3.new(0,-5,0)
v.Rotation = Vector3.new(0,0,90)
end
wait()
for i = v.Transparency,1,0.025 do ---reassures that my part gets teleported and slowly changes brick transparency.
wait(0.01)
v.CFrame = root.CFrame + Vector3.new(0,-5,0)
v.Rotation = Vector3.new(0,0,90)
    v.Transparency = i
v.CFrame = root.CFrame + Vector3.new(0,-5,0)
v.Rotation = Vector3.new(0,0,90)

end
v.Touched:connect(function(hit)
local opponent = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
    if opponent and opponent ~= player.Character.Humanoid then
        opponent:TakeDamage(dmg) 
end
end)
wait()
v:remove()
end
end

--------------------------------------------------------
wait(0.1)
script.Parent:FindFirstChild("Charging").Value = 0  
end)



0
That's probably because you have your Collisions turned on under the 'Model' tab in studio. There's a little icon you press that can turn your collisions on and off. Here's an image of it: https://gyazo.com/1c13bad654539dff83dcbcb238989614 KingLoneCat 2642 — 7y
0
Yea its off, if i was making something that gets teleported to my player, im obviously gonna turn can collision off e.e rexpex 45 — 7y
0
Like, you didn't even attempt to read my description. It says "all is well until i go next to another part." That means when the teleporting brick touches another brick, it goes over it. rexpex 45 — 7y
1
Thats because you use Rotation. Use CFrame.new(PosX,PosY,PosZ) * CFrame.Angles(math.rad(DegreeX),math.rad(DegreeY),math.rad(DegreeZ)) RubenKan 3615 — 7y
View all comments (3 more)
0
It's still not making the teleporting brick go over my head, when it touches another person.(i deleted the touch event to see if thats the problem and it still has the same effect) rexpex 45 — 7y
0
The for i,v loop for size is the problem, anyway i can keep the changing size and fix the glitch? rexpex 45 — 7y
0
Oh i fixed it, i added you script to the for i,v loop. Thanks RubenKan rexpex 45 — 7y

Answer this question