I have a script that towards the bottom says localplayer but i know a script cant use local player, so how would i find the name of the player that clicked the detector and use that instead of localplayer?
-- Variables -- local scriptFolder = script.Parent local partFolder = script.Parent.Parent.PartsAndSound -- Scripting -- partFolder.Enable.MainDetector.MouseClick:Connect(function() partFolder.Enable.Printer:Play() wait(0.1) partFolder.Enable.MainDetector:Destroy() scriptFolder.isPrinting.Value = true wait(1) scriptFolder.CP3M.Value = scriptFolder.CP3M.Value + 3000 wait(2) partFolder.CashPrinted.SurfaceGui.CashPrinted2.Text = scriptFolder.CP3M.Value partFolder.Enable.PrintedCash:Play() wait(1) scriptFolder.CP3M.Value = scriptFolder.CP3M.Value + 3000 wait(2) partFolder.CashPrinted.SurfaceGui.CashPrinted2.Text = scriptFolder.CP3M.Value partFolder.Enable.PrintedCash:Play() wait(1) scriptFolder.CP3M.Value = scriptFolder.CP3M.Value + 3000 wait(2) partFolder.CashPrinted.SurfaceGui.CashPrinted2.Text = scriptFolder.CP3M.Value partFolder.Enable.PrintedCash:Play() wait(1) scriptFolder.CP3M.Value = scriptFolder.CP3M.Value + 3000 wait(2) partFolder.CashPrinted.SurfaceGui.CashPrinted2.Text = scriptFolder.CP3M.Value partFolder.Enable.PrintedCash:Play() partFolder.Enable.SecondaryDetector.MaxActivationDistance = 15 wait(1) scriptFolder.CP3M.Value = scriptFolder.CP3M.Value + 3000 wait(2) partFolder.CashPrinted.SurfaceGui.CashPrinted2.Text = scriptFolder.CP3M.Value partFolder.Enable.PrintedCash:Play() partFolder.Enable.SecondaryDetector.MaxActivationDistance = 15 if scriptFolder.CP3M.Value == 15000 then partFolder.Enable.SecondaryDetector.MouseClick:Connect(function() game.Players.(PLAYERNAME).leaderstats.Money.Value = game.Players.(PLAYERNAME).leaderstats.Money.Value + 15000 script.Parent.Parent:Destroy() end) end end)
Hey there, ClickDetectors returns a parameter called 'playerWhoClicked', It is the player object that has clicked the detector.
To use it properly here's an example:
partFolder.Enable.MainDetector.MouseClick:Connect(function(player) -- giving the player parameter a name, in this case player local playerName = player.Name -- accessing the player's Name. end)