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
4 years ago

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

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

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)
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 — 4y
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 — 4y
1
Ok but this doesn’t help fix my problem Glacitron 239 — 4y
Ad

Answer this question