Deleted Parts Re-Appearing when i use clone function

I am making a spleef game where you can get diffrent utilities and abilities.
At the moment i am working on a fireball move where if you let go of a certain button the fireball explodes and destroys any tiles near it.

For the most part my script is working fine. However i have noticed that whenever i clone the explosion hitbox the previous ones that should have been deleted come back and it stacks over and over

This is my code

Video of the problem

And this is video showing that the parts are being deleted but for some reason every single previously deleted part is coming back and stacking

You’re connecting the 2nd RemoteEvent every single time the 1st RemoteEvent is ran.


Think of it as an increment. Everytime the OnServerEvent for the 1st RemoteEvent is called, it creates a new connection for the OnServerEvent for the 2nd RemoteEvent since it’s inside of the function that is connected to the event. This creates that “stacking effect”. My suggestion, since you’re already creating the explosion on the server anyways, is to just remove that 2nd RemoteEvent and just check when the tween has completed. Like so:

local target = {}
target.Position = HMRp.Position + (HMRp.CFrame.LookVector * 60)
local tween = TS:Create(FireballClone, TInfo, target)

tween.Completed:Wait() -- Yields until the tween is completed

-- Your explosion code here

Hope this helps :slightly_smiling_face:

1 Like

thank you but how would i go about making it explode when ever a player wants without using another function
if it waits until the tween is completed then the player will no longer be able to decide when to set off the fireball

In that case, you’ll keep both remotes. However, you want to replace the first one with a RemoteFunction. This will allow you to return the fireball created on the server to the client.

Client side:

-- Idk how your client script is structured but this is how you would implement into your own code
local fireball = RP:InvokeServer() -- Invoke the server to create and return a fireball 

-- Whenever you want to explode this fireball, just send it as the argument

Server side:

RP.OnServerInvoke = function(player)
   local fireball = Fireball:Clone()
   fireball:SetAttribute("Player", tostring(player)) -- This can be used to determine that this player owns this fireball for the 2nd event
   -- change whatever properties you need and tween the fireball as well
   return fireball -- return the fireball to the client

RP2.OnServerEvent:Connect(function(player, fireball)
   -- Check that the fireball is owned by the player
   if (fireball:GetAttribute("Player") == tostring(player)) then
      -- Create the explosion
1 Like

alright ive never even heard of remote function before tysm!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.