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

How to make part go through baseplate?

Asked by 5 years ago

So I made a script that creates a pillar that shoots up into the sky, the problem however. Is that I also need it to go through the baseplate, how can I do that using scripting?

Edit: Essentially, the script works like this: When I press a key, a pillar will spawn at your mouses position. However, when I press it anywhere near a player, it goes over said players head. I thought that by sinking it through the baseplate, that problem could be fixed. But I honestly don't know what to do and if anyone has any better ideas let me know.

Note: This is only on the receiving end of a remote, so not all variables will be stated, but you can probably guess based on what they are called and how they are used

game.ReplicatedStorage.FireTower.OnServerEvent:Connect(function(player,mousehit)
local char = game.Players[player.Name].Character
 local hum = char.Humanoid 
 local root = char.HumanoidRootPart


local fireTower = Instance.new("Part",workspace)
local fire = game:GetService("ServerStorage").Fire:Clone()
fire.Parent = fireTower
fireTower.Name = "fireTower"
fireTower.BrickColor = BrickColor.new("Deep orange")
fire.Size = NumberSequence.new(1)
fireTower.Shape = Enum.PartType.Cylinder
fireTower.CFrame = mousehit
fireTower.Size = Vector3.new(999,10,10)
fireTower.Orientation = Vector3.new(0, 0, 90)
fireTower.Material = Enum.Material.Neon
fireTower.Transparency = 0.5
fireTower.Anchored = true
fireTower.CanCollide = false
game.Debris:AddItem(fireTower, 6)
wait(3)
local tween = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Quint,Enum.EasingDirection.In,0,false,0)
local tweenProperty = {Size = Vector3.new(999,20,20)}
local tweenRun = tween:Create(fireTower,tweenInfo,tweenProperty)
tweenRun:Play()
ten = true
fireTower.Touched:connect(function(hit)
 if not ten then return end
 ten = false
 local ehum = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
 if ehum and ehum ~= hum then
  ehum:TakeDamage(30)
local debrisService = game:GetService("Debris")
local fire = game:GetService("ServerStorage"):FindFirstChild("Fire")
    for _, v in pairs(hit.Parent:GetChildren()) do
        if v:IsA("BasePart") then 
            if not v:FindFirstChild("ParticleEmitter") then
                local fireClone = fire:Clone()
                fireClone.Parent = v
                debrisService:AddItem(fireClone, 5) -- removes the object in 5 seconds

end
end 
end
for i = 1, 10 do 
    hit.Parent.Humanoid:TakeDamage(3)
    wait(0.5)
end


ten = true
else 
  return nil
end
end)
end)

0
Collisions, my friend. SBlankthorn 329 — 5y
0
Can you elaborate? DominousSyndicate 41 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Ok so your problem here that is you parent the tower to workspace first and then resize it. For some reason roblox makes it so that if a part is resized while in workspace it will reposition itself so that it is not colliding with anything. To fix this simply change the towers size before parenting it to workspace. Do this like so:

game.ReplicatedStorage.FireTower.OnServerEvent:Connect(function(player,mousehit)
local char = game.Players[player.Name].Character
 local hum = char.Humanoid 
 local root = char.HumanoidRootPart


local fireTower = Instance.new("Part") -- here we remove the parent parameter as we will set that later so it doesn't glitch the part into the air.
local fire = game:GetService("ServerStorage").Fire:Clone()
fire.Parent = fireTower
fireTower.Name = "fireTower"
fireTower.BrickColor = BrickColor.new("Deep orange")
fire.Size = NumberSequence.new(1)
fireTower.Shape = Enum.PartType.Cylinder
fireTower.CFrame = mousehit
fireTower.Size = Vector3.new(999,10,10)
fireTower.Orientation = Vector3.new(0, 0, 90)
fireTower.Material = Enum.Material.Neon
fireTower.Transparency = 0.5
fireTower.Anchored = true
fireTower.CanCollide = false
fireTower.Parent = workspace -- add it here and now it won't go in the air.
game.Debris:AddItem(fireTower, 6)
wait(3)
local tween = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Quint,Enum.EasingDirection.In,0,false,0)
local tweenProperty = {Size = Vector3.new(999,20,20)}
local tweenRun = tween:Create(fireTower,tweenInfo,tweenProperty)
tweenRun:Play()
ten = true
fireTower.Touched:connect(function(hit)
 if not ten then return end
 ten = false
 local ehum = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
 if ehum and ehum ~= hum then
  ehum:TakeDamage(30)
local debrisService = game:GetService("Debris")
local fire = game:GetService("ServerStorage"):FindFirstChild("Fire")
    for _, v in pairs(hit.Parent:GetChildren()) do
        if v:IsA("BasePart") then 
            if not v:FindFirstChild("ParticleEmitter") then
                local fireClone = fire:Clone()
                fireClone.Parent = v
                debrisService:AddItem(fireClone, 5) -- removes the object in 5 seconds

end
end 
end
for i = 1, 10 do 
    hit.Parent.Humanoid:TakeDamage(3)
    wait(0.5)
end


ten = true
else 
  return nil
end
end)
end)

0
Thanks alot, it worked, il keep this in mind in the future as well DominousSyndicate 41 — 5y
Ad

Answer this question