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
5 years ago
Edited 5 years ago

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

    local player = game.Players.LocalPlayer

local clone = game.Workspace.Handgun:Clone()

local mouse = script.Parent.MouseClick:Connect(function(mouse)

if mouse then

clone.Parent = player.Backpack

end

end)

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 — 5y
0
the script parent is the ClickDetector @NickAtNick Zero_Tsou 175 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 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.
local Clickdect = --the location of your click detector
local klone = game.Workspace.Hangun.clone()
Clickdect.MouseClick:Connect(function()
    klone.Parent = game.Player.LocalPlayer.Backpack
end)
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 — 5y
Ad
Log in to vote
0
Answered by
Imperialy 149
5 years ago

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

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

Answer this question