UPDATE: I figured it out. LocalScripts can clone from storage but they aren't good at it. See my answer below.
I have a tool that shoots a fireball. When the tool is activated, it makes a clone of a fireball that's in the lighting (not sure if this is the best place to store this stuff?). It then shoots the fireball wherever the mouse is pointed.
However, when it comes into contact with any part, it's supposed to stop and detonate. I have a Touched event in a script inside the fireball that's supposed to connect whenever it touches a part. However, when in the server, the event simply never fires, and the fireball continues to pass through everything. Again, the touched event fires just fine in simulation testing, but is unresponsive in the server test.
This is the script that's the child of the fireball:
damage = {script.Parent.Damage.lvl1.Value, script.Parent.Damage.lvl2.Value, script.Parent.Damage.lvl3.Value, script.Parent.Damage.lvl4.Value, script.Parent.Damage.lvl5.Value} baseDamage = script.Parent.Damage.lvl1 script.Parent.Touched:connect(function(part) local owner = script.Parent.Owner.Value local timer = script.Parent.Timer.Value local humanoid = part.Parent:FindFirstChild("Humanoid") local player = game.Players:FindFirstChild(owner) if humanoid then if part.Parent.Name ~= owner then explosion(Instance.new("Explosion"), script.Parent.Position) humanoid:TakeDamage(damage[player.Stats.Level.Value]) if humanoid.Health <= 0 then local creator = Instance.new("StringValue") creator.Parent = humanoid creator.Value = owner creator.Name = "Killer" local deathby = Instance.new("StringValue") deathby.Parent = humanoid deathby.Value = script.Parent.Name deathby.Name = "DeathBy" end script.Parent:Destroy() end else if part.Name ~= "Handle" then explosion(Instance.new("Explosion"), script.Parent.Position) script.Parent:Destroy() end end end) function explosion(instance, location) instance.Parent = game.Workspace instance.Position = location instance.BlastPressure = 0 instance.BlastRadius = 2 end
I've had this script working before, I'm just not sure what has caused the touched event to go unresponsive in the server.
I think your problem might have been trying to get the player's character. Try this:
damage = {script.Parent.Damage.lvl1.Value, script.Parent.Damage.lvl2.Value, script.Parent.Damage.lvl3.Value, script.Parent.Damage.lvl4.Value, script.Parent.Damage.lvl5.Value} baseDamage = script.Parent.Damage.lvl1 function explosion(instance, location) instance.Parent = game.Workspace instance.Position = location instance.BlastPressure = 0 instance.BlastRadius = 2 end script.Parent.Touched:connect(function(part) local owner = script.Parent.Owner.Value local timer = script.Parent.Timer.Value local player = game.Players:GetPlayerFromCharacter(part.Parent) local humanoid = player.Character:WaitForChild("Humanoid") if humanoid then if player.Name ~= owner then explosion(Instance.new("Explosion"), script.Parent.Position) humanoid:TakeDamage(damage[player.Stats.Level.Value]) if humanoid.Health <= 0 then local creator = Instance.new("StringValue") creator.Parent = humanoid creator.Value = owner creator.Name = "Killer" local deathby = Instance.new("StringValue") deathby.Parent = humanoid deathby.Value = script.Parent.Name deathby.Name = "DeathBy" end script.Parent:Destroy() end else if part.Name ~= "Handle" then explosion(Instance.new("Explosion"), script.Parent.Position) script.Parent:Destroy() end end end)
Hope this helped!
Okay, so I figured it out, but it was actually unrelated to the code I posted.
I was cloning the fireball, which I moved from Lighting to ReplicatedStorage, using a local script in the spell tool. Turns out that everything would clone just fine, but all the scripts would be broken/nonfunctional. I found this out after I noticed all my other scripts weren't working. I used a regular script and everything ran just fine.
So essentially, cloning items with LocalScripts can be done, but it breaks the scripts in the cloned item.