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

The part isn't removing instantly. [?]

Asked by 8 years ago
Edited 8 years ago

Hello, I've made a simply fire ball script. (Fully FE)

There is a local script inside player's backpack so when player hits the button (x) then it sends a request to remote event to fire.

Server script does all the work. But the main problem lies in Affect Script

I'm not sure how to explain it but I'll try my best :)

When the ball hits the player it should instantly remove but instead of it goes a bit further and then removes. For me it stutters. Somehow it works good in solo mode.

Is there any way to "fix" it? Have you ever had such a problem?

Server script gives the affect script to the ball

Here is the Affect Script:

local ServerStorage = game:GetService("ServerStorage")
local LightExplosion = ServerStorage:WaitForChild("Effects"):WaitForChild("Explosions"):WaitForChild("LightExpl"):Clone()
local DarkExplosion = ServerStorage:WaitForChild("Effects"):WaitForChild("Explosions"):WaitForChild("DarkExpl"):Clone()

local Magic = script.Parent
local Owner = script:WaitForChild("Owner")
local Type = script:WaitForChild("Type")

Magic.Touched:connect(function(Hit) --- HERE IS THE TOUCHED EVENT ---

local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
local Torso = Hit.Parent:FindFirstChild("Torso")

--- CHECKS IF THE PLAYER HAS HUMANOID ---
if Humanoid and Humanoid.Health > 0 and Torso and Hit.Parent.Name ~= Owner.Value then 
if Type.Value == "DShot1" then  
-------
local BodyVel = Magic:FindFirstChild("BodyVelocity"):Clone()    
DarkExplosion.Parent = Torso
game.Debris:AddItem(DarkExplosion,0.5)
script.Parent = Hit.Parent
Humanoid:TakeDamage(30)
Magic:remove()--- MAGIC == BALL THAT SHOULD BE REMOVED INSTANTLY AFTER IT TOUCHES SOMETHING ---
wait(0.2)
DarkExplosion.Enabled = false
BodyVel.Parent = Torso
wait(0.1)
BodyVel:remove()
script:remove()
------
end
end 
end)
0
Try removing the BodyVel before the wait(.2) and use :Destroy(), :remove() is deprecated. Master_JJ 229 — 8y

2 answers

Log in to vote
1
Answered by 8 years ago

First thing, use Destroy() as remove() is deprecated.

http://wiki.roblox.com/index.php?title=API:Class/Instance/Remove

Secondly, I think the ball going further is due to lag. It works good in solo mode because the server and the client are the same person. Try in game to see if the same lag is happening.

Ad
Log in to vote
1
Answered by
P100D 590 Moderation Voter
8 years ago

Your magic item is probably removing slowly due to client/server lag of the operations before it. Try removing it first, and you should see less lag.

Also: Please use :Destroy() instead of :remove()

Remove is deprecated for good reason.

Answer this question