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

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

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)

3 comments

0

scripts dont work in replicated storage

0

^^^

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

1 answer

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)

3 comments

0

Uh no. Lighting should never be used for storage. This will not change anything, leave your tool in ReplicatedStorage.

0

It worked for me last time I had a similar problem

0

Still doesnt work

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