I am making a script for my friend for his racing game. It gives me no error, but It says that there is an unknown global (that I set) is being use. In the Script:
local T = game.Workspace["Add script for laps"].Tester1
local F = game.Workspace["Add script for laps"].Finish
win = nil
over = false
function Create(player)
local new = Instance.new("BoolValue")
local new2 = Instance.new("IntValue")
new.Name = "LapAntiCheat"
new.Parent = player
new2.Name = "LapNum"
new2.Parent = player
end
function Detect1(ob)
if ob.Parent.Humanoid ~= nil then
local P = ob.Parent.Name
if game.Players[P].LapAntiCheat.Value == true then
game.Players[P].LapNum.Value = game.Players[P].LapNum.Value + 1
game.Players[P].LapAntiCheat.Value = false
if game.Players[P].LapNum.Value == 3 then
over = true
win = P
wait(5.1)
over = false
win = nil
end
end
end
end
function Detect2(ob)
if ob.Parent.Humanoid ~= nil then
local P = ob.Parent.Name
game.Players[P].LapAntiCheat.Value = true
end
end
game.Players.PlayerAdded:connect(Create)
game.Workspace["Add script for laps"].Finish.Touched:connect(Detect1)
game.Workspace["Add script for laps"].Tester1.Touched:connect(Detect2)
In the local script:
function player()
if over == true then
game.Players.LocalPlayer.PlayerGui.ScreenGui.Winner.Text = "The Winner of this race is" .. win
game.Players.LocalPlayer.PlayerGui.ScreenGui.Winner.Visible = false
wait(5)
game.Players.LocalPlayer.Character.Humanoid.Health = 0
end
end
over.Changed:connect(player)

1 comment
Best answer here.