im trying to make it so when you get a certain amount of kills it gives you a tool, but when cloning it from a server script its only doing it on the client
the tool is showing in my backpack but on the server its not showing
Server script:
local Shar2 = game.ReplicatedStorage.Sharingan2
game.ReplicatedStorage.Events.GiveShar2.OnServerEvent:Connect(function(player)
if player.Backpack:FindFirstChild("Sharingan1") then
player.Backpack:FindFirstChild("Sharingan1"):Destroy()
local CloneShar2 = Shar2:Clone()
CloneShar2.Parent = player.Backpack
end
end)
Client Script:
_G.AlreadyGiven = false
game:GetService("RunService").Heartbeat:Connect(function()
local player = game.Players:GetPlayerFromCharacter(script.Parent)
if player.Backpack:FindFirstChild("Sharingan1") then
_G.AlreadyGiven = false
end
if player:WaitForChild("SharinganKills").Value >= 25 then
if not _G.AlreadyGiven then
_G.AlreadyGiven = true
game.ReplicatedStorage.Events.GiveShar2:FireServer()
end
end
end)
ive tried everything to get it working, it always clones it on the client for some reason, no matter what i do
i meant like its showing in my backpack on the client, but not on the server
its cloning on the client even though im doing it on a server script with a remote event
Can you add some images of this error. As im still baffled by “It not showing up on the server” having an image would help me better detect the issue
Does it also not apear in players backpack when unequiped?
As when items are equiped (it is in the picture) then they are located directly in the character not in the backpack.
i got it to show up in the players backpack on client and server now, but the tool just does not work, it works fine when i put it in starterpack just not when i clone it
local canSharingan = false
local Can = true
local loaded = false
local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.CharacterAdded:Wait()
local animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")
tool.Equipped:Connect(function()
print("equipped works")
if not loaded then
local pre = animator:LoadAnimation(tool.use)
pre:Play()
task.wait(0.1)
pre:Stop()
loaded = true
end
if Can then
canSharingan = true
end
tool.Activated:Connect(function()
print("click works")
if canSharingan then
canSharingan = false
Can = false
local anim = animator:LoadAnimation(tool.use)
anim:Play()
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
task.wait(0.1)
tool.Handle.equip:Play()
task.wait(0.3)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
tool.thing:FireServer(true)
local ui = tool.Handle.sharingan:Clone()
ui.Parent = game.Players.LocalPlayer.PlayerGui
local hum = game.Players.LocalPlayer.Character.Humanoid
hum.Died:Connect(function()
if ui then
ui:Destroy()
end
end)
workspace.Camera.FieldOfView = 79
for i = 35, 1, -1 do
hum.WalkSpeed = 28
ui.Frame.ImageLabel.TextLabel.Text = i
task.wait(1)
e = i
end
ui.Frame.ImageLabel.TextLabel.Text = e - 1
ui:Destroy()
tool.Handle.unequip:Play()
workspace.Camera.FieldOfView = 70
tool.thing:FireServer(false)
task.wait(6)
Can = true
canSharingan = true
end
end)
end)
tool.Unequipped:Connect(function()
canSharingan = false
end)
server script:
script.Parent.thing.OnServerEvent:Connect(function(player, type)
player:FindFirstChild("SharinganActive").Value = type
end)
Also make sure that the value does actualy get loaded
If there are any errors or prints missing in the output bar be sure to reply with the information
Local character = player.Character or player.CharacterAdded:Wait
As otherwise when the player’s char has loaded, CharacterLoaded wont fire again when you clone it, thus leading to an infinite yield and crashing the script at the nearest character mention by making it wait infinitly.