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

How Can I Get The Weapon Through Click?

Asked by 4 years ago
Edited 4 years ago

I was making a weapon that you can only get if you click it, not touch it

The ScrewDriver is the Main Mesh Inside the ScrewDriver (Mesh) There is a Script,ClickDetector,ScrewDriver The other screwdriver that is the child of the screwdriver is the mainweapon, a tool

local weapon = script.Parent
local Click = script.Parent.ClickDetector
local mainweapon = script.Parent.ScrewDriver
local player = game.Players.LocalPlayer
local playerlocation = game.Players:FindFirstChild(""..player.Name)

Click.MouseClick:Connect(function()
    mainweapon.Parent = playerlocation
end)

But nothin is working, How can i fix this? please help

i also tried

local weapon = script.Parent
local Click = script.Parent.ClickDetector
local mainweapon = script.Parent.ScrewDriver
local player = game.Players.LocalPlayer

Click.MouseClick:Connect(function()
    mainweapon.Parent = player.Name.Backpack
end)

Please Help, Advanced Thanks!

0
Are you getting any errors in your Output? Ziruken 139 — 4y
0
the tool is a tool and has a handle right AltNature 169 — 4y
0
Ill edt it AltNature 169 — 4y

1 answer

Log in to vote
0
Answered by
AltNature 169
4 years ago
Edited 4 years ago

access the players Backpack not name you dont need to because name is a string value of the localplayers name not the actual player

local weapon = script.Parent
local Click = script.Parent.ClickDetector
local mainweapon = script.Parent.ScrewDriver


Click.MouseClick:Connect(function(Player)
    mainweapon.Parent = Player.Backpack
end)
0
how would this work with a server script? Gameplayer365247v2 1055 — 4y
Ad

Answer this question