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

When I touch the brick the Venomshank I put in Lighting does not Spawn in my backpack. Help?

Asked by
Proflts 15
9 years ago
01numofkills = game.Workspace.LeaderboardV3.leaderstats.KOs.Value
02 
03script.Parent.Touched:connect(function()
04    if numofkills == 0 then
05         for i, v in pairs(game.Players:GetChildren()) do
06        if v.Backpack ~= nil then
07clone2 = game.Lighting.Venomshank:Clone()
08clone2.Parent = v.Backpack
09            end
10        end
11    end
12end)

here is the leaderboard script as well

001print("Leaderboard script version 3.00 loaded")
002 
003 
004function onPlayerEntered(newPlayer)
005 
006 
007    local stats = Instance.new("IntValue")
008    stats.Name = "leaderstats"
009 
010    local kills = Instance.new("IntValue")
011    kills.Name = "KOs"
012    kills.Value = 0
013 
014    local deaths = Instance.new("IntValue")
015    deaths.Name = "Wipeouts"
View all 127 lines...

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

Hey. We didn't need the leaderboard script, since your first script gives us everything we need. To get the player from a character, use the GetPlayerFromCharacter method. Any questions? Comment!

1script.Parent.Touched:connect(function(hit)
2    if game.Players:GetPlayerFromCharacter(hit.Parent) then
3        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
4        if (player.leaderstats.KOs.Value == 0) and not player.Backpack:findFirstChild("Venomshank") then
5            game.Lighting.Venomshank:clone().Parent = player.Backpack
6        end
7    end
8end)
0
thanks bro appreciate it. i just gave the leaderboard script incase that you needed to fix an error in the other script. that could have possibly had a false variable. But THANK YOU so much bro. Proflts 15 — 9y
0
No problem. That leaderboard script looks like it came from the ROBLOX Staff, and it's highly unlikely for it to error, unless you tamper with it. Shawnyg 4330 — 9y
0
yeah it did lol im not advanced in scripting that much. im more of a beginner/ advanced i dont know everything. Proflts 15 — 9y
Ad

Answer this question