Giving the tool to someone who did something

Hello,

So i’m working with tools now, but the only thing is that I don’t know how I can make it that the tool only is going to be given to the player who did something.

This is how far I came with the script;

script.Parent.Triggered:Connect(function(player)
	local tool = script.Parent.Parent:Clone()
	tool.Name = "Box"
	tool.Parent = game.Players.
end)

Can someone help me with this?

2 Likes

Try this:

tool.Parent = game.Players[player].Backpack

Shouldn’t this line;

local Player = game.Players:GetPlayerFromCharacter(player.Parent)

be this?;

local Player = game.Players.GetPlayerByUserId(player.Parent)

Sadly this doesn’t works, any other suggestions?

script.Parent.Triggered:Connect(function(player)
local tool = script.Parent.Parent:Clone()
tool.Name = “Box”
tool.Parent = game.Players:WaitForChild(“Backpack”)
end)
So as the player triggers the proximityprompt (I am pretty sure this event is used for that )
The cloned Tool will go into the player’s backpack
my script and it works fine for me


So imagine the player already has the tool and you don’t want to give him the same tool twice
so now what u do is check if he already has that tool and if he doesnt then give him the tool like this

how it works:
https://gyazo.com/14c0b3cf292759a5417b040541035369

Doesn’t works either, do you got any other suggestions?

Then can you provide us the picture of the explorer ?
I have provided you with the scripts and explained a bit and also shown a video how it works but I am not really being able to find out what problem is happening on your end
Try running the scripts I provided

image

The following script should work.

script.Parent.Triggered:Connect(function(player)
	local tool = script.Parent.Parent:Clone()
	tool.Name = "Box"
	tool.Parent = player.backpack
end)

Doesn’t works either, is this working for you guys cause isn’t that odd?

I corrected a typo, and lessened it a bit. Can you see if this works?

script.Parent.Triggered:Connect(function(player)
	local tool = script.Parent.Parent:Clone().Parent = player.Backpack
	tool.Name = "Box"
end)

Doesnt works either, any other suggestions?

You must have messed up something else, because it is evidently not the script. Could you send screenshots of the Developer Console? Do so by pressing F9 or typing /console in chat.

Ok, I already know how I can get devconsole.

This is the client;

This is the server;

This?

script.Parent.Touched:Connect(function(hit)
local tool = script.Parent.Parent:Clone()
tool.Name = "Box"
tool.Parent = game.Players[hit.Parent.Name].Backpack
end)

It’s a proximity prompt, so you can’t touch it.

2 Likes

Oh, I thought it was a part touch, my bad.

Is the script written in a local script? Also where is the tool located?

As far as I am aware, on the fourth line it says:

You haven’t finished off there, however, I’m not a scripter so I cannot help as much.

The script is NOT a localscript and its in serverscriptserver within a folder.