Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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?

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 soutpansa 120 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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.

0
I corrected the error on line 10 but it still doesn't work Lukeisbossman64 73 — 7y
0
Hmm MrLonely1221 701 — 7y
0
I changed my code. Try it now? MrLonely1221 701 — 7y
0
nope Lukeisbossman64 73 — 7y
View all comments (2 more)
0
How about instead of checking if the player's team color is the same, you check if "player.Team == green"? MrLonely1221 701 — 7y
0
this is before you join a team, you're on the nuetral team when you start Lukeisbossman64 73 — 7y
Ad

Answer this question