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

Clicking for a tool isn't working for some reason?

So when the player clicks the item, they get a 'Bear' of which is in Replicated Storage, and it's then added to the player's startergear. When I click and reset, I've not been given the item. Am I missing some code? Did I mistype anything? I also need it so the player can only get the item once and it- (extra; disappears?) Please help me, I'm a little stuck ;-;

script.Parent.ClickDetector.MouseClick:connect(function(player)
		local plr = game.Players:findFirstChild(player.Name)
		game.ReplicatedStorage.Bear:Clone().Parent = player.StarterGear
		wait (3)
	end

2 comments

0

(Also If for the extra (disappears part) I need it to only for the player.

0

The Player parameter already refers to the Player Object of the Client that clicked... You must also use a Server-sided Script in workspace, as it is a globalized environment.

3 answers

✓ Accepted answer

Adding the tool to the player's startergear will make the player get the item every time they respawn. You should replace player.StarterGear with player.Backpack

	game.ReplicatedStorage.Bear:Clone().Parent = player.Backpack

4 comments

0

I need it so it stays in their inventory

0

add another line under it game.ReplicatedStorage.Bear:Clone().Parent = player.StarterGear

0

It didn't work? I'm confused sorry

0

what do you mean by didn't work? doesn't stay or something else? (also if it didn't work you can just unaccept the answer)

For the gear, it would be Backpack and not StarterGear (if you wanted the gear to not be in the player's backpack every time the player respawn)

I would also change the find first child thing.

Although I haven't tested the script yet, I am certain that it works.

script.Parent.ClickDetector.MouseClick:connect(function(player)
        local plr = game.Players:GetPlayerFromCharacter(player.Parent)
        game.ReplicatedStorage.Bear:Clone().Parent = player.Backpack
        wait (3)
    end

Ok so there are stuff to fix and also add, and i will also help you with getting the tool once so i really hope my scripts works and helps you.

local db = false

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	if not db then
		db = true
        	local plr = game.Players:GetPlayerFromCharacter(player.Parent)
		local bear = game.ReplicatedStorage.Bear
		bear:Clone().Parent = player.Backpack
		wait(9^9^9) --This will wait inf so the player wont get the tool again :)
		db = false
	end
end)

1 comment

0

Sry about the indentation tho

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