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

Added Player.Teamcolour if statement, now does not work or give error. What is wrong?

Asked by 8 years ago

Added Player.Teamcolour if statement, now does not work or give error. What is wrong?

local serverstore = game:GetService("ServerStorage")
local players = game:GetService("Players")

local cavalry = serverstore:WaitForChild("Cavalry Sword")

local groupid = 1141913

players.PlayerAdded:connect(function(player)
    if player:IsInGroup(groupid) then
        if player.TeamColor==BrickColor.new("Bright red") then  
            player.CharacterAdded:connect(function()
            cavalry:Clone().Parent = player.Backpack 
            end)
        end
    end
end)
3
Do they spawn on "Bright red" team right when they join the game, or do they have to switch to that team when they get into the game. Because your if then statement is looking for it the player is already on Bright red, otherwise it just exits out of the if statement and ends the function. M39a9am3R 3210 — 8y
0
Mega is right. When are they going to be on the 'Bright red' team? Because when this script runs they likely won't be on it. Perci1 4988 — 8y
0
There is several teams, you spawn on a neutral team, then use a TeamChange GUI to get onto the Bright Red team siradamfletcher 0 — 8y

1 answer

Log in to vote
-1
Answered by 8 years ago

It looks to me like you are trying to access the ServerStorage. Players cannot access the ServerStorage, try ReplicatedStorage instead:

local serverstore = game:GetService("ReplicatedStorage")--added replicatedstorage
local players = game:GetService("Players")

local cavalry = serverstore:WaitForChild("Cavalry Sword")

local groupid = 1141913

players.PlayerAdded:connect(function(player)
    if player:IsInGroup(groupid) then
if player.TeamColor==BrickColor.new("Bright red") then  
        player.CharacterAdded:connect(function()
        cavalry:Clone().Parent = player.Backpack 
        end)
    end
 end
end)

All you need to do is move your tool into replicatedstorage. Hope I helped!

0
LocalScripts can't access server storage, but since PlayerAdded doesn't work well in LocalScripts, we can deduce that this is a server Script. Perci1 4988 — 8y
Ad

Answer this question