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

How would I make the tool detect the player that is using the tool?

local db = true
script.Parent.Touched:connect(function(hit)
	if hit.Name == "pickuparea" then game.Players:FindFirstChild("Humanoid")
		if db == true then
			db = false
			script.Parent.Transparency = 1
			local player = script.Parent.Touched
			player.leaderstats.Robux.Value = player.leaderstats.Robux.Value + 10
			script.Parent.Sound:Play()
			script.Parent.Transparency = 1
			wait(60)
			db = true
			script.Parent.Transparency = 0
		end
	end	
end)

I need the script to detect the player that is using the tool, so that the player can be rewarded with currency. I need help ASAP and it will be greatly appreciated

1 comment

0

A thing you need to get noticed, don't use ROBUX as your stat name. A popular tycoon maker got banned by doing a ROBUX tycoon, that give people think the tycoon really gives ROBUX. so, honestly, just do it to Money, cash, or coins. Thanks, and sorry that I posted something that not suit to this helping website.

1 answer

✓ Accepted answer

Edit :

From what I understand, you want the part of the tool, in this case the "handle", to touch the object and the player earn an amount of money.

So that's it here :


script.Parent.Touched:Connect(function(hit)
	
if hit.Parent.Name == "Tool" then
	
local findplayer = game.Players:FindFirstChild(hit.Parent.Parent.Name)	
	
if findplayer ~= nil then
	
findplayer.leaderstats.Robux.Value = findplayer.leaderstats.Robux.Value + 1
	
end	
	
end	
	
end)

2 comments

0

This works, but how would i make it to where when the part of the tool touches the object, it gives you currency?

0

I edited the comment, see if that's it

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