Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My script d'ont want to give a Team some points ??

   while true do
   wait(15)
    for i,v in pairs(game.Players:GetPlayers()) do
    local hum = v.Character:WaitForChild("Humanoid")
    	if v:FindFirstChild("Leaderstats") then
    		if v.Team == game.Teams.Playing then
    			v.Leaderstats.Coins = v.Leaderstats.Coins + amount
    			v.WinSound:Play()
    			wait(2)
    			v.Team = game.Teams.Lobby
    			hum.Health = 0
    		end
    	end
    end
    end

4 comments

0

explain more idioit

0

what script did you use Server Script or local?

0

ServerScript

0

Nothing appear on the output when it was suppose to say it

1 answer

General Practice

Use :GetService() to retrieve the Players and Team Services

Use :WaitForChild() to make sure something exists before using or changing it

Issues

When you want to change the "Coins" value under "Leaderstats" you have to specify the property Value so that it will change, otherwise you are attempting to alter the Coins IntValue directly, not its property.

Revised Server Script

local amount = 25 -- amount you are giving to the player

while true do
    wait(15)
    for i, v in pairs(game:GetService("Players"):GetPlayers()) do
	    local hum = v.Character:WaitForChild("Humanoid")
	    if v:FindFirstChild("Leaderstats") then
		    if v.Team == game:GetService("Teams"):WaitForChild("Playing") then
			    local coins = v:WaitForChild("Leaderstats"):WaitForChild("Coins")
			    coins.Value = coins.Value + amount
			    v:WaitForChild("WinSound"):Play()
			    wait(2)
			    v.Team = game:GetService("Teams"):WaitForChild("Lobby")
			    hum.Health = 0
			end
	    end
    end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.