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

Why is this point giving script not working?

Asked by 8 years ago

This script is supposed to give a team points every second if they hold down a point on the map.

However, the script isn't working.

Can someone please help me?

Here's what output gave me: 21:48:06.226 - Workspace.Map.KotH.PointGiver:18: attempt to index local 'Dude' (a nil value)

Here's the 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
    if game.ServerScriptService.MainGameScript.Variables.GameMode.Value == "King of the Hill" and script.Parent.Owner.Value ~= nil then
        if game.ServerScriptService.MainGameScript.Variables.Playing.Value == true then
            local Dude = game.Players:FindFirstChild(script.Parent.Owner.Value)
            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
    wait(1)
end

1
What value type is owner? String? If it is then .Value will never be equal to nil so 'script.Parent.Owner.Value ~= nil' won't do anything, change nil to "" so it checks that the value is not empty. General_Scripter 425 — 8y
0
It is an object value CoolJohnnyboy 121 — 8y

Answer this question