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

Help with giving players items when game starts?

Asked by 9 years ago
local player = game.Players.LocalPlayer

local weapon = false

local serverstorage = game:GetService("ServerStorage")
local laser = serverstorage:FindFirstChild("Classes"):FindFirstChild("Laser")
local rocket = serverstorage:FindFirstChild("Classes"):FindFirstChild("Rocket")
local demo = serverstorage:FindFirstChild("Classes"):FindFirstChild("Demo")
local assault = serverstorage:FindFirstChild("Classes"):FindFirstChild("Assault")

game:GetService("ReplicatedStorage"):FindFirstChild("StatusTag").Changed:connect(function(value)
    if value == "Match in Progress" then
        while true do
            if weapon == false then
                if player.Class.Value == "Laser" then
                    weapon = true
                    local weapon = laser:FindFirstChild("Phaser")
                    weapon:Clone().Parent = player.Backpack
                    weapon:Clone().Parent = player.StarterGear
                elseif player.Class.Value == "Rocket" then
                    weapon = true
                    local weapon = rocket:FindFirstChild("Launcher")
                    weapon:Clone().Parent = player.Backpack
                    weapon:Clone().Parent = player.StarterGear                   
                elseif player.Class.Value == "Demo" then
                    weapon = true
                    local weapon = demo:FindFirstChild("Grenade")
                    weapon:Clone().Parent = player.Backpack
                    weapon:Clone().Parent = player.StarterGear                  
                elseif player.Class.Value == "Assault" then
                    weapon = true
                    local weapon = assault:FindFirstChild("Rifle")
                    weapon:Clone().Parent = player.Backpack
                    weapon:Clone().Parent = player.StarterGear      
                end
            end
            wait(1)
        end
    end
end)

This is a LocalScript inside the StarterPack. It works to an extent. It gives you a phaser if you are the class laser and the game has started. But if you change mid way through the game and die and you stay with the phaser, and not get the other gun. I don't know how to get this to work.

1 answer

Log in to vote
1
Answered by 9 years ago

This may work. I used an old school longhand version. I didn't test this, so tell me if it works.

local player = game.Players.LocalPlayer

wep = false

local serverstorage = game:GetService("ServerStorage")
local laser = serverstorage:FindFirstChild("Classes"):FindFirstChild("Laser")
local rocket = serverstorage:FindFirstChild("Classes"):FindFirstChild("Rocket")
local demo = serverstorage:FindFirstChild("Classes"):FindFirstChild("Demo")
local assault = serverstorage:FindFirstChild("Classes"):FindFirstChild("Assault")

game:GetService("ReplicatedStorage"):FindFirstChild("StatusTag").Changed:connect(function(value)
    if value == "Match in Progress" then
        while true do
            if wep == false then
                if player.Class.Value == "Laser" then
                    if wep == true then
                        player.StarterGear:ClearAllChildren()
                        local weapon = laser:FindFirstChild("Phaser")
                        local back=weapon:Clone() 
                        back.Parent=player.Backpack
                        local start=weapon:Clone() 
                        start.Parent=player.StarterGear
                    elseif wep==false then
                        local weapon = laser:FindFirstChild("Phaser")
                        local back=weapon:Clone() 
                        back.Parent=player.Backpack
                        local start=weapon:Clone() 
                        start.Parent=player.StarterGear
                    end
                elseif player.Class.Value == "Rocket" then
                    if wep == true then
                        player.StarterGear:ClearAllChildren()
                        local weapon = rocket:FindFirstChild("Launcher")
                        local back=weapon:Clone()
                        back.Parent=player.Backpack
                        local start=weapon:Clone()
                        start.Parent = player.StarterGear
                    elseif wep==false then
                        local weapon = rocket:FindFirstChild("Launcher")
                        local back=weapon:Clone()
                        back.Parent=player.Backpack
                        local start=weapon:Clone()
                        start.Parent = player.StarterGear  
                    end                 
                elseif player.Class.Value == "Demo" then
                    if wep == true then
                        player.StarterGear:ClearAllChildren()
                        local weapon = demo:FindFirstChild("Grenade")
                        local back=weapon:Clone() 
                        back.Parent = player.Backpack
                        local start=weapon:Clone() 
                        start.Parent = player.StarterGear 
                    elseif wep==false then
                        local weapon = demo:FindFirstChild("Grenade")
                        local back=weapon:Clone() 
                        back.Parent = player.Backpack
                        local start=weapon:Clone() 
                        start.Parent = player.StarterGear
                    end                  
                elseif player.Class.Value == "Assault" then
                    if wep == true then
                        player.StarterGear:ClearAllChildren()
                        local weapon = assault:FindFirstChild("Rifle")
                        local back=weapon:Clone()
                        back.Parent = player.Backpack
                        local start=weapon:Clone()
                        start.Parent = player.StarterGear
                    elseif wep==false then
                        local weapon = assault:FindFirstChild("Rifle")
                        local back=weapon:Clone()
                        back.Parent = player.Backpack
                        local start=weapon:Clone()
                        start.Parent = player.StarterGear
                    end      
                end
            end
            wait(1)
        end
    end
end)

0
doesnt work, theres no errors NinjoOnline 1146 — 9y
Ad

Answer this question