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

Help me please! How to do it? (value). HELP!!!!!llllllllllllllllll

Asked by 5 years ago
Edited 5 years ago

I want to make that after counting all the players threw for one team. I made the count in another script and the problem is not this. The problem in this -----------------------------------------ServerScriptService.Script:4: attempt to index local 'player' (a nil value)

The script itself

local player = game.Players.LocalPlayer

if game.Workspace.NYGNO.BrickColor == BrickColor.new("Lily white") then player.TeamColor = BrickColor.new("Forest green") end

Where is the script

ServerScriptService \ Script

0
A normal script can't get the LocalPlayer, only client-sided scripts can Rare_tendo 3000 — 5y
0
you would have to get the player from some event, like touched theking48989987 2147 — 5y

1 answer

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

A normal Script doesn't use LocalPlayer (only LocalScript does). You have to use another method to get the player. Here are some ideas what you can get player from:

I. 'Touched' event. This event fires, when player touches given part, for example:

script.Parent.Touched:connect(function(hit) -- Hit is a part of character which actually touched the part (left leg, head, right arm etc.)
    local player = hit.Parent -- Here's the player :)
    -- Do anything you want.
end)

II. Player joining the game. Event 'PlayerAdded' fires whemever any player joins the game:

game:GetService("Players").PlayerAdded:connect(function(player) -- Player is actually here, you don't need to write a variable :)
    -- Do anything you want here
end)

I hope I helped :D

Ad

Answer this question