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

Why does my script not work when its cloned from Replicated storage?

Basically what happens is I try to clone a tool from ReplicatedStorage using this script

local ServerStorage = game:GetService("ReplicatedStorage")
local tool = ServerStorage:FindFirstChild("Cigaratte")
local player = game:GetService("Players").LocalPlayer
local cloned = false

script.Parent.Activated:Connect(function()
	if not cloned then 
		cloned = true
		tool:Clone().Parent = player.Backpack
	end
	wait(5)
	cloned = false
end)

Once I have cloned this tool it shows up in my inventory and I can select it and hold it, however any animations/Interactions and my activated function doesn't work, basically everything in this script

local player = game:GetService("Players").LocalPlayer
local Character = player.CharacterAdded:wait() or player.Character
local Humanoid1 = Character:WaitForChild("Humanoid")
local smk = script.Smoking
local LoadAnimation1 = Humanoid1:LoadAnimation(smk)
local IsSmoking = false
local Cigaratte = script.Parent.Part
local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(
	30, -- Time
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	0, -- RepeatCount (when less than zero the tween will loop indefinitely)
	false, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime
)
 
local tween = TweenService:Create(Cigaratte, tweenInfo, {Size = Vector3.new(0.45, 0.086, 0.086)})

script.Parent.Activated:Connect(function()
	LoadAnimation1:Play()
	IsSmoking = true
	wait(1)
	tween:Play()
end)

script.Parent.Deactivated:Connect(function()
	LoadAnimation1:stop()
	IsSmoking = false
	tween:Cancel()
end)

Both scripts are local scripts, I also have an Animation whose parent is the script above.

1 answer

✓ Accepted answer

Make sure this is in StarterPlayerScript

Script:

local ServerStorage = game:GetService("ReplicatedStorage")
local tool = ServerStorage:FindFirstChild("Cigaratte")
local player = game:GetService("Players").LocalPlayer
local cloned = false

script.Parent.Activated:Connect(function()

  tool:Clone().Parent = player.Backpack
   if cloned then
        if tool.Activated then
    end
    wait(5)
    cloned = false
end)

3 comments

1

But it has to be in the tool in the starter pack or else the player won’t see it? Or can they access the tool using starter character scripts

0

I mean put it in starterpack because obviously this is where tools go. What I meant is that if you just want to make a script print or do something you can just put it starterplayerscript. Not for tools or guis 

1

Ok but this doesn’t help fix my problem

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