local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0
points.Parent = leaderstats
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
Made a new script still doesnât work. Here it is :
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0
points.Parent = leaderstats
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
local buttonbluemap1 = game.ReplicatedStorage.Obbys.Obby1.ButtonBlue.Button.ClickDetector
local buttonredmap1 = game.ReplicatedStorage.Obbys.Obby1.ButtonRed.Button.ClickDetector
local buttonbluemap2 = game.ReplicatedStorage.Obbys.Obby2.ButtonBlue.Button.ClickDetector
local buttonredmap2 = game.ReplicatedStorage.Obbys.Obby2.ButtonRed.Button.ClickDetector
local function buttonpressed(player)
local leaderstats = player.leaderstats
local points = leaderstats.Points
points.Value = points.Value + 10
end
buttonbluemap1.MouseClick:Connect(buttonpressed)
buttonredmap1.MouseClick:Connect(buttonpressed)
buttonbluemap2.MouseClick:Connect(buttonpressed)
buttonredmap2.MouseClick:Connect(buttonpressed)
for _,Buttons in pairs(game.ReplicatedStorage.Obbys.Obby1:GetChildren()) do
if string.match(Buttons.Name, "Button") then
for _, CD in pairs(Buttons:GetChildren()) do
if CD:IsA("ClickDetector") then
CD.MouseClick:Connect(buttonpressed)
end
end
no, its a for loop that finds all buttons that has the word âButtonâ, then it looks for a ClickDetector, it executes it for all of the buttons instead of one of them
Yeah when the round begins two players are being teleported to the map an also the map changes randomly. Right now i have two different test maps, one of them will be teleport to the workspace and so also the two buttons of the map
Try parenting the increment script to the clickdetector or reparenting the entire test map instead of cloning it. If that doesnât fix the issie, it may be something else.
I changed the script so the test map itâs self will change parent to workspace and back to replicated storage but i get this error âThe Parent property of Obby1 is locked, current parent: NULL, new parent ReplicatedStorageâ and also i have infinte yield possible for