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

Gear possibly not cloning correctly. What is going wrong here?

Asked by 3 years ago

I have an event (RemoteEvent) that fires on all of the clients. When this happens the game is supposed to clone a sword into everyone's inventory. This works without errors, but the sword is unusable, when trying to use it, it simply doesn't do anything. I suspect this has to do with the script that clones the gear. The following script is a local script located in StarterGui:

local Players = game:GetService("Players")
local Events = game.ReplicatedStorage.Events

Events.DefaultModeStart.OnClientEvent:Connect(function()
    wait(15)
    game.ReplicatedStorage.ClassicSword:Clone().Parent = game.Players.LocalPlayer.Backpack
end)

This is the script that fires the event: (Script located in Workspace) What this is supposed to do is wait 15 seconds, teleport the players, then clone the gear.

local Events = game.ReplicatedStorage.Events
Events.DefaultModeStart:FireAllClients() -- Start Event

-- TP Players
wait(15)
target = CFrame.new(175.5, 68.5, 1247.5)
for i, player in ipairs(game.Players:GetChildren()) do
    --Make sure the character exists and its HumanoidRootPart exists
    if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
        --add an offset of 5 for each character
        player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
    end
end
0
The same thing happens to me catsalt29 57 — 3y
0
what i do know is that if you look in your gear the script isn't in it catsalt29 57 — 3y

1 answer

Log in to vote
0
Answered by
Elyzzia 1294 Moderation Voter
3 years ago

when you clone a tool on the client, any server-side code won't run

the classic sword has a lot of code on the server so. it won't work, of course

to fix it you just have to clone the tool on the server instead of the client

for i, player in ipairs(game.Players:GetPlayers()) do
    game.ReplicatedStorage.ClassicSword:Clone().Parent = player.Backpack
end
0
Hmmm. The sword equips, although the sword isn't usable still. User#37681 0 — 3y
0
Maybe, the script is in the wrong place? User#37681 0 — 3y
0
Ah, figured it out. Thank you! User#37681 0 — 3y
Ad

Answer this question