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

Why is my tool not working when it is in replicatedstorage or serverstorage?

Asked by 4 years ago

It for some reason doesn't work, as I have a tool which does is clones the tool into the users backpack. I tested it in starterpack, which it worked, but when I input it in the script of that tool and cloned it to the backpack, it for some reason doesnt function. This is the local script of my tool i have been trying to make work.

local tool = script.Parent
local player = game.Players.LocalPlayer
local rp = game:GetService("ReplicatedStorage")
local hum = player.CharacterAdded:Wait():WaitForChild("Humanoid")
local TweenService = game:GetService("TweenService")
local mouse = player:GetMouse()
local BarrageEvent = rp:WaitForChild("VampiricBarrage")
local holdingdown = false

local holdingdowncooldown =  0.66666668653488
--[[
tool.Activated:Connect(function()
    BarrageEvent:FireServer(tool)
end)
]]
function checkTool(character,toolName)
     for _, v in pairs(character:GetChildren()) do 
        if v:IsA("Tool") then 
            if v.Name == toolName then
                return true
            end
        end
    end
    return false
end
mouse.Button1Down:Connect(function()
    if checkTool(player.Character,tool.Name) then
        holdingdown = true
        repeat 
            BarrageEvent:FireServer(tool)
            wait(holdingdowncooldown)
        until not holdingdown
    end
end)

mouse.Button1Up:Connect(function()
    if checkTool(player.Character,tool.Name) then
        holdingdown = false 
    end
end)

tool.Unequipped:Connect(function()
    holdingdown = false
end)
0
scripts dont work in replicated storage greatneil80 2647 — 4y
0
^^^ Ziffixture 6913 — 4y
0
It was cloned in replicated storage, and then parented into player backpack, And even if I put the tool into workspace, It still wont function baba7860 7 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

You need to put it in lighting because it doesn't work in replicated storage,You just need to put the item in Lighting instead of replicated storage

local tool = script.Parent
local player = game.Players.LocalPlayer
local rp = game:GetService("Lighting")
local hum = player.CharacterAdded:Wait():WaitForChild("Humanoid")
local TweenService = game:GetService("TweenService")
local mouse = player:GetMouse()
local BarrageEvent = rp:WaitForChild("VampiricBarrage")
local holdingdown = false

local holdingdowncooldown =  0.66666668653488
--[[
tool.Activated:Connect(function()
    BarrageEvent:FireServer(tool)
end)
]]
function checkTool(character,toolName)
     for _, v in pairs(character:GetChildren()) do 
        if v:IsA("Tool") then 
            if v.Name == toolName then
                return true
            end
        end
    end
    return false
end
mouse.Button1Down:Connect(function()
    if checkTool(player.Character,tool.Name) then
        holdingdown = true
        repeat 
            BarrageEvent:FireServer(tool)
            wait(holdingdowncooldown)
        until not holdingdown
    end
end)

mouse.Button1Up:Connect(function()
    if checkTool(player.Character,tool.Name) then
        holdingdown = false 
    end
end)

tool.Unequipped:Connect(function()
    holdingdown = false
end)
0
Uh no. Lighting should never be used for storage. This will not change anything, leave your tool in ReplicatedStorage. Ziffixture 6913 — 4y
0
It worked for me last time I had a similar problem FluffySheep46209 369 — 4y
0
Still doesnt work baba7860 7 — 4y
Ad

Answer this question