So i want to detect when the player clicks so i can give them points though my script wont work, it shows no errors or anything, it is a local script inside of the GUI
local ReplicatedStorage = game:GetService("ReplicatedStorage") while true do wait(0.01) if ReplicatedStorage.PlayerLoaded == true then print("load successful for "..game.Players.LocalPlayer.Name) script.Parent.Frame.Visible = true local Cooldown = false local Mouse = game.Players.LocalPlayer:GetMouse() Mouse.Button1Down:Connect(function() if Cooldown == false then ReplicatedStorage.ClickEvent:FireServer() Cooldown = true wait(0.1) Cooldown = false end end) end end
I wouldn't recommend listening to Mouse.Button1Down in a while true loop. I would do something like this:
local ReplicatedStorage = game:GetService("ReplicatedStorage") -- repeating the wait() function until PlayerLoaded is true, aka yielding repeat wait() until ReplicatedStorage.PlayerLoaded.Value == true print("load successful for "..game.Players.LocalPlayer.Name) script.Parent.Frame.Visible = true local Cooldown = false local Mouse = game.Players.LocalPlayer:GetMouse() Mouse.Button1Down:Connect(function() print("mouse click") if Cooldown == false then print("cooldown disabled") ReplicatedStorage.ClickEvent:FireServer() Cooldown = true wait(0.1) Cooldown = false end end)
I've added two more prints for debugging (lines 12 and 14)