Can someone tell me how I can make it so whenever I click on a part(it has a click detector) it will give me items from the server storage, although only people in a certain group can get the tools?
Thanks.
Can someone tell me how I can make it so whenever I click on a part(it has a click detector) it will give me items from the server storage, although only people in a certain group can get the tools?
Thanks.
Do a script where the logic clones the items and sets its Parent to the player in the workspace. Sorry ye I cant type codes on linux
aka
game.serverstorage.item:Clone()
item.Parent = game.Workspace.player
script.Parent.MouseClick1:Connect(function()
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
local item = game:GetService("ServerStorage").Item:Clone()
item.Parent = v.Backpack
end
That would be the script to replicated the item to backpack. i believe
For me just putting the item in the player works,
and I think he wants to put it in a the clicker.
I’m trying to make it so that if an officer wants to get their tools, they can just click the locker and it would give them their tools.
I’ve made this so far.
local ClickDetector = game.Workspace.PartForCLick.Script.ClickDetector
ClickDetector.MouseClick1:Connect(function()
game.ServerStorage.M4:Clone()
game.ServerStorage.M4.Parent = game.Players.LocalPlayer.Backpack
end)
Would that work?
You can also put in the player, but place in the backpack for me insures the players get the item the first time.
The Script has the ClickDectector, why?
Idk, thats just how I was taught to use click detectors.
it is it a local script? or a regular script?
Regular, Script. But I just realized I should probably change that.
yeah you cant say localplayer in a regular script. It wont work.
local ClickDetector = game.Workspace.PartForCLick.Script.ClickDetector
ClickDetector.MouseClick1:Connect(function()
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
local item = game:GetService("ServerStorage").Item:Clone()
item.Parent = v.Backpack
end
That should work. I just took some of your code and implemented it into mines.
Didn’t work - OOOOOOOOOOOOF
@CoolGuyBoiBruh @hauntedzx MouseClick1
is not an event of ClickDetector. I think you meant MouseClick
. Also, I do not think he wants to give everyone the tool.
The MouseClick
event passes the player who clicked as the first parameter. So your script would look like this:
local ClickDetector = game.Workspace.PartForClick.Script.ClickDetector
ClickDetector.MouseClick1:Connect(function(player)
if player:GetRankInGroup(123) >= 456 then -- replace 123 with group id 456 with minimum rank id
game.ServerStorage.M4:Clone()
game.ServerStorage.M4.Parent = player.Backpack
end
end)
Also, I put in a check that you will have to modify yourself to limit who can receive the tools.
Simple, put the tools in server storage, or wherever you please. And then you have to find the players model! and simply parent the part to the players model, I will put the script to find the players model here, please make your on click script.
local player = game.Players.LocalPlayer -- finds local player
local PlayerModel = workspace:WaitForChild(player.Name,1) -- here this script will find the players model, so whenever you need to parent the tool simply put "Tool.Parent = PlayerModel"
So umm nothing worked for some reason. Really weird right.
have you tried my recommendation yet?
Hmm… I will try replicating your script and making it work