Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Creating a Tool Dispenser? Or 'Giver?'

I am currently trying to create a cafe for a group owned by a friend of mine and was having trouble figuring out how to make a giver that would dispense a specific tool on touch. Basically like the coffee machines, etc. you would see behind the counter of any ROBLOX personal server cafe. I've never done anything like this before, so please help me! Thanks.

1 answer

✓ Accepted answer

First you would need a script inside of the "giver" or the block that gives the tool. Next, you would basically just need to do is something like this inside the script:

Tool=game.Lighting.Tool --Find the tool here

script.Parent.Touched:connect(function(Part) --Fires when brick is touched
	if Part.Parent:FindFirstChild("Humanoid") then --Checks if a character touched
		local Player=GetPlayerFromCharacter(Part.Parent)
		Tool:clone().Parent=Player.Backpack --Clones tool and gives to player
	end
end)

Anyways, if you edit it correctly to find the tool, everything should work perfectly fine. If you have any further questions please leave a comment below. Hope I helped :P

3 comments

0

I ran into a problem with 'Player=GetPlayerFromCharacter(Part.Parent)' It kept telling me to ' try using local' and if I ever did it would ask for an identifier instead. Do you think you could help me with that? Thank you.

0

Sure. All you would need to do is put Local before defining the variable. I'm not sure if this is what your problem is, but I think it should be fixed.

0

Thanks so much for all the help! :D

This discussion is preserved as it was. New answers, comments, and votes are closed.