Hi there, I’ve tried the usual suspects for this - however, no matter what I’ve tried, it just seems to break the actual code of the tool when giving it to me.
I realise this seems like a problem with the framework of the tool and not the script, however, I can’t change the tool’s scripts as that’s not an option.
Current script:
local players = {"Player1"}
local gear = game.ReplicatedStorage.Weapons["Tool name"]
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(chr)
for i = 1, #players do
if players[i] == plr.Name then
gear:Clone().Parent = plr:WaitForChild("Backpack")
end
end
end)
end)
The tool gets stored in replicated storage but when the game retrieves it, the “ability” of the tool only client sided and the effects and animations don’t play for the other player - I tested it on a local server.
Therefore, my question is how can I create a script that keeps the tool within “StarterPack” but doesn’t appear to over players and only the owner (me).
local owner = "your user id"
local players = game.Players
players.PlayerAdded:Connect(function(player)
if player.UserId = owner then
local tool = game.StarterPack["tool"]:Clone()
tool.Parent = player.Backpack
end
end)
It means that people who well as many call it “hack” can just get the tool even if they shouldnt, thats why this wouldnt be the most recommended method unless you want cheaters to get this tool too.
The problem seems to be that the tool in of itself is only appearing client-sided and not displaying for the player it’s attacking - it should be noted that the tool is an ability and not a physical handle either.
I know I’m not giving much to work with here but are there any common reasons a tool being stored in serverstorage would break?
Ok well probably put the tool inside of ServerStorage in a folder or something.
And sense the question wasnt answered, this is a server script right? also are you using a local script to handle the entire tool? Like damage, cooldowns(If you have them), etc?
This is what you need to do to give a tool to only yourself when you join the game, and keep that tool even if you die or reset (server Script in ServerScriptService):
local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local OWNER_USER_ID = 173412116
local tool = ServerStorage.Weapons["Tool name"]
local function onPlayerAdded(player)
if player.UserId == OWNER_USER_ID then
tool:Clone().Parent = player.StarterGear
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
For this to work correctly you’ll need to place the Tool inside of a Folder named “Weapons” which is inside of ServerStorage
Cheers, I appreciate it but it seems my scripts won’t work around anything outside StarterPack - I’m guessing this is just the framework/design of my scripts so I’m just going to refine.
But it’s odd, the attack works on both screens when I put the tool inside of StarterPack but when I put it inside serverstorage it just shows client-sided view and doesn’t work on the player it’s attacking.
I do think you’ll need to reconsider your current framework if it’s causing you this kind of problem, it shouldn’t make a difference where a Tool is stored in the way it replicates unless some of the code inside of your Tool is able to run when the Tool is unequipped