Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[Edit] Why won’t this part stay anchored?

This script charges up an orb, after a remote is fired, the orb is supposed to grow in front of your head, the problem is that the orb wont grow. I have tried tweening and lerping.

[Edit] Now that I fixed that error, another one has appeared, Now the part falls through the baseplate whenever It spawns. I tried welding and anchoring. In other words, I’m trying to figure out how to make the orb stay put in front of my face.

game.ReplicatedStorage.Moves.OnServerEvent:Connect(function(plr,key,mousehit)
if key == "Blast" then
local char = plr.Character
local hum = char.HumanoidRootPart
local charging = Instance.new("Part")
charging.Name = "Blast"
charging.Transparency = 0.5
charging.Material = Enum.Material.Neon
charging.Shape = Enum.PartType.Ball
charging.Size = Vector3.new(0.1,0.1,0.1)
charging.CanCollide = false
charging.BrickColor = BrickColor.new("Really red")
charging.Parent = workspace

local head = char.Head
local weld = Instance.new("Weld")
charging.CFrame = char.Head.CFrame * CFrame.new(0,0,-2)
weld.Part0 = head
weld.Part1 = charging
weld.C0 = head.CFrame:Inverse()
weld.C1 = charging.CFrame:Inverse()
weld.Parent = charging

local function charge()
        local chargingPart = charging:Clone()
        chargingPart.Parent = charging
        chargingPart.CanCollide = false
        chargingPart.Transparency = 0.5
        chargingPart.Shape = Enum.PartType.Ball
        chargingPart.Material = Enum.Material.Neon
        chargingPart.BrickColor = BrickColor.new("Really red")
        chargingPart.Size = Vector3.new(0.1,0.1,0.1)
        chargingPart.CFrame = charging.CFrame * CFrame.new(math.random(-0.6,0.6),math.random(-0.6,0.6),math.random(-0.6,0.6))
        chargingPart.Anchored = true
        charging.Size = Vector3.new(charging.Size.X + 0.01,charging.Size.Y + 0.01, charging.Size.Z + 0.01) --Issue: The orb wont expand using lerp or tweening, if someone could explain why I would also appreciate it
        game.Debris:AddItem(chargingPart,0.01)
end

for i = 0,1,0.01 do
    spawn(charge)
    wait(0.01)
end
wait()
charging:Destroy()
end
end)

2 comments

0

Why are you cloning "charging" and changing its properties again? They're already set, that's irrelevant.

0

You have a point, but will this solve my issue?

1 answer

See if this works:

game.ReplicatedStorage.Moves.OnServerEvent:Connect(function(plr,key,mousehit)
if key == "Blast" then
local char = plr.Character
local hum = char.HumanoidRootPart
local charging = Instance.new("Part")
charging.Name = "Blast"
charging.Anchored = true
charging.Transparency = 0.5
charging.Material = Enum.Material.Neon
charging.Shape = Enum.PartType.Ball
charging.Size = Vector3.new(0.1,0.1,0.1)
charging.CanCollide = false
charging.BrickColor = BrickColor.new("Really red")
charging.Parent = workspace

local head = char.Head
local weld = Instance.new("Weld")
charging.CFrame = char.Head.CFrame * CFrame.new(0,0,-2)
weld.Part0 = head
weld.Part1 = charging
weld.C0 = head.CFrame:Inverse()
weld.C1 = charging.CFrame:Inverse()
weld.Parent = charging

local function charge()
        local chargingPart = charging:Clone()
        chargingPart.Parent = charging
        chargingPart.CFrame = charging.CFrame * CFrame.new(math.random(-0.6,0.6),math.random(-0.6,0.6),math.random(-0.6,0.6))
        charging.Size = Vector3.new(charging.Size.X + 0.01,charging.Size.Y + 0.01, charging.Size.Z + 0.01) --Issue: The orb wont expand using lerp or tweening, if someone could explain why I would also appreciate it
        game.Debris:AddItem(chargingPart,0.01)
end

for i = 0,1,0.01 do
    spawn(charge)
    wait(0.01)
end
wait()
charging:Destroy()
end
end)

I didn't play with anything regarding the orb expanding as you said that you had fixed it already. But what I did was remove the unnecessary properties for chargingPart since its' properties is identical to charging. Then I added a property to charging saying charging.Anchored = true.

5 comments

0

Thanks, il try it when I get back home. If it doesn’t work I will let you know.

0

No it does not work, it just stays anchored in the spot instead of in front of my characters face.

0

You do have knowledge on how to manipulate the position property, right?

0

I answered the question you have asked and your "new" problem wasn't asked. I'd consider starting a new question more specific to this "new" problem of having the object in front of the character's face.

0

Next time, ask a question that covers all your problems needing a solution.

This discussion is preserved as it was. New answers, comments, and votes are closed.