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)
I will take a big guess and say: Events
Events are used as communication between scripts. Lets say you have a script and a localscript, like you. Here we will make the baseplate a random color when a part is touched!
Script
local event = Instance.new("RemoteEvent") -- Create a new Event event.Parent = game.Workspace -- Give it a parent event.Name = "Communication" -- Give it a name event.OnServerEvent:connect(function() -- Giving the event a function print ("Old brickcolor is ".. game.Workspace.Baseplate.BrickColor) game.Workspace.Baseplate.BrickColor = BrickColor.Random() -- Running your code print ("New brickcolor is ".. game.Workspace.Baseplate.BrickColor) end)
LocalScript
part = instance.new("Part") -- Creating a part part.Parent = game.Workspace -- Give it a parent part.Touched:connect(function(hit) -- If the part is touched: game.Workspace.Communicationt:FireServer() -- The event we made will be fired! end)
Here is the link for the Wiki tutorial: http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial I hope this answered your question.