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

Why Does Cloning a Speed Coil from Replicated Storage Break It?

I've tested the coil by putting it into StarterPack, and whenever I do so it seems to work fine. However, when I move it into ReplicatedStorage and use the following game pass script to clone it, the item is placed into my backpack but remains nonfunctional.

local player = game.Players.LocalPlayer
local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,00000)

if ownsGamepass then
 local scoil = game:GetService("ReplicatedStorage"):WaitForChild("speedcoil"):Clone()
 scoil.Parent = player.Backpack
end

It should also be noted that the script is placed in a LocalScript within StarterGui.

3 comments

0

LocalScripts cannot clone scripts to function, use a ServerScript instead

0

I have a similar script for the grapple hook and that seems to work fine. Why is there a disparity in these two results?

0

I believe it could be because of how both items function

3 answers

Try putting the script in starter character/player scripts.

Maybe try to reference the Replicated Storage in the beginning of the script instead of the end

Example...

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

And on and on with the rest of your code.

Hello!

I have reviewed your script! And from my understanding, it appears that you were able to clone a working Grapple Hook with a Gamepass LocalScript however the SpeedCoil didn't work when trying the same script. I believe the issue comes to how both items function, as well as LocalScripts not being able to clone scripts to function. So, in your case, you would need to insert a ServerScript in ServerScriptService, name it anything, and from then use a PlayerAdded function so the game can reward the player the gamepass item upon joining. Here is the script you would like to use for a ServerScript instead:

local GamepassID = 000000 --Change 000000 to your gamepass ID
local ReplicatedStorage = game:GetService("ReplicatedStorage")

game.Players.PlayerAdded:Connect(function(Player)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, GamepassID) then
		ReplicatedStorage.speedcoil:Clone().Parent = Player.Backpack
	end
end)

Also note: I have kept your item name as speedcoil so you won't need to change any names as well as kept ReplicatedStorage as the keeper of the item, however, since this is a ServerScript, I suggest using ServerStorage instead of ReplicatedStorage

Hope this helped you, if so, please accept my answer!

1 comment

0

By any chance is there a way to make it so that if you die you will spawn with it again?

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