Before You Decide To Take My Post Down Please Know That I Am Not Allowed On The Roblox Dev Website.
I'm Not Sure How To Change This On Touched To An On Clicked.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage.RemoteEvent local Sold = RemoteEvent.ItemSold local Debounce = false script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player.leaderstats.Gems.Value >= 5000 then if Debounce == false then Debounce = true Player.leaderstats.Rebirth.Value = Player.leaderstats.Rebirth.Value + 1 Player.leaderstats.Gems.Value = Player.leaderstats.Gems.Value - 5000 script.CashRegister:Play() wait(5) Debounce = false end end end end)
You can use a click detector which has two separate events for left mouse click and right mouse click. The mouse click event also supports other platforms.
local part = script.Parent; local clickDetector = Instance.new('ClickDetector', part); clickDetector.MouseClick:connect(function(player) --player parameter returns the player instance of the person who clicked end)