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

How you give a player a tool that's been Clicked Like in Prison life?

Asked by
Zero_Tsou 175
6 years ago
Edited 6 years ago

I just tried this script and i don’t know why it didn’t work can you help me out?

01    local player = game.Players.LocalPlayer
02 
03local clone = game.Workspace.Handgun:Clone()
04 
05local mouse = script.Parent.MouseClick:Connect(function(mouse)
06 
07if mouse then
08 
09clone.Parent = player.Backpack
10 
11end
12 
13end)

How do you give players a tool when the mouse get clicked like in Prison Life!
Thank you for reading this!

0
it isn't working because u use 'mouse' which is gonna make you receive if u click ur mouse only, use clickdetector instead and descend it into a `BrickPart` and redo your script. NickAtNick 163 — 6y
0
the script parent is the ClickDetector @NickAtNick Zero_Tsou 175 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

When answering, if your answer does not fully solve the question, it should be written as a comment to the question instead of as an answer.
1local Clickdect = --the location of your click detector
2local klone = game.Workspace.Hangun.clone()
3Clickdect.MouseClick:Connect(function()
4    klone.Parent = game.Player.LocalPlayer.Backpack
5end)
0
You are trying to put an event into an if statement and thats why It's not working. If this doesn't work, tell me and I will try to help you. DreamInspired 61 — 6y
Ad
Log in to vote
0
Answered by
Imperialy 149
6 years ago

you can not use localscripts inside of a click detector it must be a serverscript

1script.Parent.MouseClick:Connect(function(player)
2    print(player.Name)
3end)
0
everything else you wrote should work Imperialy 149 — 6y

Answer this question