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

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

Asked by 5 years ago

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.

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 User#20279 0 — 5y
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 User#20279 0 — 5y
0
K thanks, I'll look at those Your_Momdotcom 91 — 5y
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 Your_Momdotcom 91 — 5y
View all comments (3 more)
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. sleazel 1287 — 5y
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. Your_Momdotcom 91 — 5y
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 User#20279 0 — 5y

1 answer

Log in to vote
-1
Answered by 5 years ago

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.

0
it shouldn't although connect is deprecated, it will still work. Also, changing the wait time won't matter theking48989987 2147 — 5y
0
That didn't do anything Your_Momdotcom 91 — 5y
0
Try changing all of the "script.Parent" to "Part" hawkinator8554 -2 — 5y
0
well played. Your iq is officially -10 greatneil80 2647 — 4y
Ad

Answer this question