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

Growing Spheres and Touched events, how to solve this problem?

Asked by 8 years ago

I've been trying to create a growing 'nuke' using a simple sphere that will call breakjoints on any object it hits (right now it only does this with players, I haven't updated it yet.. I need to solve this problem first). I've been having trouble with it however, because due to the touched event whenever a player walks into it or touches it, while growing it will fly up above the players head. is there any solution to this problem? I've thought of working with the bricks position or something, but that's a bit difficult to do and I'm sure there is a more simple solution.

(in the actual code the first bit comes later on, I just pulled these two out of the larger script)


for i = 0.2, 1000, 3 do script.Parent.Size = Vector3.new(i, 0, i) wait(0.1) end end end end) script.Parent.Touched:connect(function(hit) if script.Parent.Transparency == 1 then return end if hit.Parent:FindFirstChild("Humanoid") then hit.Parent:BreakJoints() end end )

1 answer

Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
8 years ago

You are going to have to reposition the sphere by changing it's CFrame property each time you adjust the size. Luckily this is quite easy, as we only need to set it's CFrame to a constant value each time you adjust the size.

local sphere = script.Parent
local cframe = sphere.CFrame

for i = 0.2, 1000, 3 do
    sphere.Size  = Vector3.new(i, i, i)
    sphere.CFrame = cframe
end
Ad

Answer this question