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

Tools are not moving from ReplicatedStorage to the player's Backpack?

hello i iz back

So I have a Part called purple. When a player touches it, the player gets a two tools. The problem is neither of the tools are entering the player's Backpack.

The Script:

local storage = game:WaitForChild("ReplicatedStorage")
local cancollecttools = true
local shank = storage:WaitForChild("PurpleShank")
local power = storage:WaitForChild("Gyroball")
local teams = game:WaitForChild("Teams")
local green = teams:WaitForChild('Purple')
script.Parent.Touched:connect(function(hit)
	local character = hit.Parent
	local player = game.Players:GetPlayerFromCharacter(character)
	if player ~= nil and cancollectsword == true  then
		player.TeamColor = green.TeamColor
		shank:Clone().Parent = player.Backpack
		power:Clone().Parent = player.Backpack
		cancollecttools = false
	end
end)

The output says nothing. Help?

1 comment

0

Could you use the model from this video instead? Just change the giver block to look like the purple one, and use it to give you your tools. It should work: https://www.youtube.com/watch?v=EiZJAcFg-iU https://www.roblox.com/library/93174228/Masterkunfu-Giver-pack

1 answer

The problem is you're using the wrong variable on line 10:

local storage = game:GetService("ReplicatedStorage")
local cancollecttools = true
local shank = storage:WaitForChild("PurpleShank")
local power = storage:WaitForChild("Gyroball")
local teams = game:GetService("Teams")
local green = teams:WaitForChild('Purple')
script.Parent.Touched:connect(function(hit)
    local character = hit.Parent
    local player = game.Players:GetPlayerFromCharacter(character)
    if player ~= nil and cancollecttools == true  then
        player.TeamColor = green.TeamColor
        shank:Clone().Parent = player.Backpack
        power:Clone().Parent = player.Backpack
        cancollecttools = false
    end
end)

I hope this helped. If it did please accept this as the answer. If it didn't feel free to ask any questions you have about it.

6 comments

0

I corrected the error on line 10 but it still doesn't work

0

Hmm

0

I changed my code. Try it now?

0

nope

0

How about instead of checking if the player's team color is the same, you check if "player.Team == green"?

0

this is before you join a team, you're on the nuetral team when you start

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