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

Point giving script not working?

Asked by 8 years ago

This script is supposed to give a team points every second for holding down a certain point. The "Owner" value (an ObjectValue) is nil until someone claims it, and that one person's name becomes the value of the "Owner" value.

The script is then supposed to find the team of the "Owner" and give his/her team points every second.

However, the script doesn't work. I received output, however.

Output: 12:35:50.999 - Argument 1 missing or nil 12:35:51.000 - Script 'Workspace.Map.KotH.PointGiver', Line 15

Script:

local DD = game.ServerScriptService.MainGameScript.Variables:WaitForChild("DD")
local GG = game.ServerScriptService.MainGameScript.Variables:WaitForChild("GG")
local BB = game.ServerScriptService.MainGameScript.Variables:WaitForChild("BB")
local RR = game.ServerScriptService.MainGameScript.Variables:WaitForChild("RR")

repeat 
wait()
until script.Parent:findFirstChild("Owner")

while true do
    local Dude = game.Players:FindFirstChild(script.Parent.Owner.Value)
    if game.ServerScriptService.MainGameScript.Variables.Playing.Value == true then
        if game.ServerScriptService.MainGameScript.Variables.GameMode.Value == "King of the Hill" then
            if Dude ~= nil then
                if Dude.TeamColor == BrickColor.new("Bright green") then
                    GG.Value = GG.Value + 1
                elseif Dude.TeamColor == BrickColor.new("Bright red") then
                    RR.Value = RR.Value + 1
                elseif Dude.TeamColor == BrickColor.new("Bright blue") then
                    BB.Value = BB.Value + 1 
                elseif Dude.TeamColor == BrickColor.new("Bright yellow") then
                    DD.Value = DD.Value + 1 
                end         
            end
        end
    end
    wait(1)
end

1 answer

Log in to vote
0
Answered by 8 years ago

The Object value is being set to the player itself, yet you try to use game.Players:FindFirstChild on the object value?

Either do:

local Dude = game.Players:FindFirstChild(script.Parent.Owner.Value.Name)

or just grab the value directly and do:

local Dude = script.Parent.Owner.Value

Also the error suggests that you're trying to access the owner when there is no value set, so I'd add an if statement to make sure that Owner.Value ~= nil

Ad

Answer this question