简体   繁体   中英

Roblox Lua Give LocalPlayer weapon doesn't work,

My code: https://justpaste.it/87evk

local original = game:GetService("ReplicatedStorage"):FindFirstChild("CloneSmoke")
 
local tool = script.Parent
local copy = original:Clone()
 
tool.Activated:Connect(function()
print("Running...")
local sound = script.Parent.Sound
 
copy.Parent = script.Parent.Handle
sound:Play()
wait(3)
tool:Destroy()
local plr = game.Players.LocalPlayer
local weapon = game.ReplicatedStorage.Jutsus.Momoshiki["Momoshikis Sword"]
local w2 = weapon:Clone()
w2.Parent = plr.Backpack
end)

Idk what i have to do here to get the Player and give him a Weapon.I tried much but i dont get the right Soloution.
It were nice wenn you help me

First off, make sure this is in a LocalScript

Also change local original = game:GetService("ReplicatedStorage"):FindFirstChild("CloneSmoke") to local original = game:GetService("ReplicatedStorage"):WaitForChild("CloneSmoke") This is because the script loads faster than items in the game, so chances are, the sword hasn't loaded into the game by the time the script runs; the script won't work if it doesn't find the object you are trying to reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM