Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a script stored in an object in Replicated Storage work when cloned?

It's been a while since I've used Roblox studio, and there have been some changes with the way scripts run. Anyways, the problem is that the cannonball that I'm firing Isn't exploding. When I press the f button, the cannonball fires, but it doesn't explode when it hits something. The code below is the script that is in the cannonball.

script.Parent.Touched:connect(function(part)
	local explosion = Instance.new("Explosion", script.Parent)
	explosion.Position = script.Parent.Position
	wait(.1)
	script.Parent:Destroy()
end)

Everything looks completely fine in this script, and even when I try to print sentences, it does absolutely nothing. Nothing that is put in the script does anything. The cannonball is stored in Replicated Storage, and the script is not disabled. When I press f to fire the cannon, the cannonball is cloned from Replicated Storage, and a body velocity is inserted into it for it to move. It's extremely odd and I have absolutely no idea why it doesn't work.

7 comments

1

Are you cloning the cannonball through a local script? If so, that would probably be why the script inside the cannonball isn’t working. You can use remote events to fix this : https://developer.roblox.com/articles/Remote-Functions-and-Events

1

And assuming you’ve haven’t used Roblox Studio for a very long time, the cause of this is FilteringEnabled. It’s been forced on for all games now and now games work like this : https://developer.roblox.com/articles/Roblox-Client-Server-Model

0

K thanks, I'll look at those

0

I read up on it, but I am still unsure as to how I'm supposed to use :FireServer() in my local script when I clone the cannonball

0

I would put cannonball into ServerStorage. This way you cannot clone it from client and will force you to do it right first time. Your local script then should ask server to clone the cannonball (passing position), and the server should handle the rest.

0

Okay, I figured it out, but there is like a half second delay where the cannonball appears and then begins to zoom in the target direction. It kind of pisses me off that this was so difficult, especially since the previous method worked perfectly without delay.

0

^ If you don’t like the delay, there’s a tutorial that should help you get rid of it. It’s also really strange on how this tutorial is almost EXACTLY like your problem : https://developer.roblox.com/articles/Fighting-Against-Lag

1 answer

First of all, change connect to "Connect" and change ".1" to "0.1"

This should fix the problem.

If it still doesn't, comment back.

4 comments

0

it shouldn't although connect is deprecated, it will still work. Also, changing the wait time won't matter

0

That didn't do anything

0

Try changing all of the "script.Parent" to "Part"

0

well played. Your iq is officially -10

This discussion is preserved as it was. New answers, comments, and votes are closed.