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

When I added a script, the rest broke, can you fix it?

Hi there! I'm making a game where the players points update by one every second. I need the points to start updating only when the player steps on a model, called "Game." Here is my script, which doesn't work. Can you fix it?

local Players = game:GetService("Players")
	local UpdatePoints = false
	local function onTouch(part)
	    return end
	end
	part.Touched:Connect(onTouch) 
	Players.PlayerAdded:Connect(function(Player)   
		    Player.CharacterAdded:Connect(function(Character)
			        UpdatePoints = true
			 
			        local Leaderstats = Instance.new("Folder")
			        Leaderstats.Name = "leaderstats"
			        Leaderstats.Parent = Player
			 
			        local Points = Instance.new("IntValue")
			        Points.Name = "Points"
			        Points.Parent = Leaderstats
			 
			        Player.leaderstats.Points.Value = 0
			 
			        local Humanoid = Character.Humanoid
		        Humanoid.Died:Connect(function()
				            UpdatePoints = false
				            Player.leaderstats.Points.Value = 0
			        end)
			 
			        while (UpdatePoints) do
				            wait(1)
			            Player.leaderstats.Points.Value += 1
				            if not (UpdatePoints) then
					                break
				            end
				        end
			    end)
end)

1 comment

0

I don't understand the return end part?

1 answer

✓ Accepted answer

On your Touched function you have an extra end, so

local Players = game:GetService("Players")
local UpdatePoints = false
local function onTouch(part)
	return end
end

--should be
local Players = game:GetService("Players")
local UpdatePoints = false
local function onTouch(part)
	return 
end

The rest looks fine! :)

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