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

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

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

2 comments

0

The same thing happens to me

0

what i do know is that if you look in your gear the script isn't in it

1 answer

✓ Accepted answer

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

3 comments

0

Hmmm. The sword equips, although the sword isn't usable still.

0

Maybe, the script is in the wrong place?

0

Ah, figured it out. Thank you!

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