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

part going onto my head?

Asked by
theCJarmy7 1293 Moderation Voter
8 years ago
player = game.Players.LocalPlayer
char = player.Character
hum = char:WaitForChild("Humanoid")

script.Parent.Equipped:connect(function(mouse)
    mouse.Button1Down:connect(function()
        local h = Instance.new("Part")
        h.Name = player.Name
        h.Size = Vector3.new(23,23,23)
        h.Position = char.Torso.Position
        h.TopSurface = "Smooth"
        h.BrickColor = BrickColor.new("Bright yellow")
        h.Shape = "Ball"
        h.CanCollide = false
        h.Transparency = .5
        h.Anchored = true
        h.Parent = game.Workspace--]]
local mouse = player:GetMouse()
local mousedown = false
local Event

mouse.Button1Up:connect(function()
    local s = game.ReplicatedStorage.healhit:Clone()
    s.Parent = h
    h.Position = char.Torso.Position
    char.Torso.Anchored = false
    mousedown = false
    game:GetService("Debris"):AddItem(h,1)
    Event:disconnect()
end)

Event = mouse.Button1Down:connect(function()
    h.Position = char.Torso.Position
    char.Torso.Anchored = true
  mousedown = true
  while mousedown do
        wait()
        h.Size = h.Size + Vector3.new(.1, .1, .1)
end
end)
    end)
    end) 

basically, this makes a ball expand around my character, but when a script gets inserted into this ball, it goes ontop of my head, even though its anchored and cancollide is false. if i take out the script cloning part, it works just fine, but i need that script inside of the part. i found out that if i put the entire script inside a comment, it works fine, so i think the problem is that i use a .touched function for the script. so what do i do to stop it from popping onto my head?

1 answer

Log in to vote
-1
Answered by 8 years ago

Position works weirdly. Since position detects collisions with other parts, the position changes to where it won't collide with anything. So your code is correct except you have to change 'Position' to 'CFrame'. This is how the code should be.

player = game.Players.LocalPlayer
char = player.Character
hum = char:WaitForChild("Humanoid")

script.Parent.Equipped:connect(function(mouse)
    mouse.Button1Down:connect(function()
        local h = Instance.new("Part")
        h.Name = player.Name
        h.Size = Vector3.new(23,23,23)
        h.CFrame  = char.Torso.CFrame -- Position to CFrame change here
        h.TopSurface = "Smooth"
        h.BrickColor = BrickColor.new("Bright yellow")
        h.Shape = "Ball"
        h.CanCollide = false
        h.Transparency = .5
        h.Anchored = true
        h.Parent = game.Workspace--]]
local mouse = player:GetMouse()
local mousedown = false
local Event

mouse.Button1Up:connect(function()
    local s = game.ReplicatedStorage.healhit:Clone()
    s.Parent = h
    h.CFrame= char.Torso.CFrame -- Position to CFrame change here
    char.Torso.Anchored = false
    mousedown = false
    game:GetService("Debris"):AddItem(h,1)
    Event:disconnect()
end)

Event = mouse.Button1Down:connect(function()
    h.CFrame  = char.Torso.CFrame --  And Position to CFrame here
    char.Torso.Anchored = true
  mousedown = true
  while mousedown do
        wait()
        h.Size = h.Size + Vector3.new(.1, .1, .1)
end
end)
    end)
    end) 

Hope I Helped !

0
didn't work, the CFrame didn't help theCJarmy7 1293 — 8y
Ad

Answer this question