I want to make that this script adds 10 points to player after they click a part and this part goes invisible, but it doesnt work.
local Part1 = script.Parent local CD = Part1.ClickDetector local function addPoint(playerpoints, part) local pointadd = 10 playerpoints.Value += pointadd part.Transparency = 1 end local function clickedPart(ClickParent) local character = ClickParent.Parent local humanoid = character:FindFirstChildWhichIsA("Humanoid") if humanoid then local player = game.Players:GetPlayerFromCharacter(humanoid.Parent) local lb = player:FindFirstChild("leaderstats") local playerpoints = lb:FindFirstChild("Points") addPoint(playerpoints, Part1) end end CD.MouseClick:Connect(clickedPart)
A ClickDetector sends over a player parameter, I'm not sure what you mean by 'ClickParent'.
local Part1 = script.Parent local CD = Part1:WaitForChild('ClickDetector') local function addPoint(Points, Part) local pointsToAdd = 10 Points.Value += pointsToAdd Part.Transparency = 1 end local function onClicked(Player) local Character = Player.Character if Character then local Humanoid = Character:FindFirstChild('Humanoid') if Humanoid then local leaderstats = Player:FindFirstChild('leaderstats') local playerPoints = leaderstats:FindFirstChild('Points') if playerPoints then addPoint(playerPoints, Part1) end end end end CD.MouseClick:Connect(onClicked)