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

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

Asked by
Glacitron 239 Moderation Voter
5 years ago

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

01local ServerStorage = game:GetService("ReplicatedStorage")
02local tool = ServerStorage:FindFirstChild("Cigaratte")
03local player = game:GetService("Players").LocalPlayer
04local cloned = false
05 
06script.Parent.Activated:Connect(function()
07    if not cloned then
08        cloned = true
09        tool:Clone().Parent = player.Backpack
10    end
11    wait(5)
12    cloned = false
13end)

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

01local player = game:GetService("Players").LocalPlayer
02local Character = player.CharacterAdded:wait() or player.Character
03local Humanoid1 = Character:WaitForChild("Humanoid")
04local smk = script.Smoking
05local LoadAnimation1 = Humanoid1:LoadAnimation(smk)
06local IsSmoking = false
07local Cigaratte = script.Parent.Part
08local TweenService = game:GetService("TweenService")
09 
10local tweenInfo = TweenInfo.new(
11    30, -- Time
12    Enum.EasingStyle.Linear, -- EasingStyle
13    Enum.EasingDirection.Out, -- EasingDirection
14    0, -- RepeatCount (when less than zero the tween will loop indefinitely)
15    false, -- Reverses (tween will reverse once reaching it's goal)
View all 32 lines...

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

1 answer

Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
5 years ago

Make sure this is in StarterPlayerScript

Script:

01local ServerStorage = game:GetService("ReplicatedStorage")
02local tool = ServerStorage:FindFirstChild("Cigaratte")
03local player = game:GetService("Players").LocalPlayer
04local cloned = false
05 
06script.Parent.Activated:Connect(function()
07 
08  tool:Clone().Parent = player.Backpack
09   if cloned then
10        if tool.Activated then
11    end
12    wait(5)
13    cloned = false
14end)
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 Glacitron 239 — 5y
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  JesseSong 3916 — 5y
1
Ok but this doesn’t help fix my problem Glacitron 239 — 5y
Ad

Answer this question