I m, Currently working, on a Clicking Simulator
and i m trying to, make a Tp, But for some reason, my script dosen’t wort, please feedback!
Script,
local deb = false
local Tp = game.Workspace:FindFirstChild("Tp")
local price = script.Parent.price.Value
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not deb then
deb = true
wait(0.5)
if player.leaderstats.Clicks.Value >= price then
player.leaderstats.Clicks.Value = player.leaderstats.Clicks.Value - 50
player.Character.HumanoidRootPart.Position = Tp.Position
deb = false
end
end
end
end)```
It looks like you’re only releasing the debounce within if player.leaderstats.Clicks.Value ... so the script would remain deb = true forever if they can’t afford the thing.
Also, you should decrement the players’ clicks by price instead of hardcoding 500.
Lastly, teleport the player using player.Character:SetPrimaryPartCFrame(Tp.CFrame) instead, manually addressing the Position of only the root part won’t give the results you expect it to.
Oh I think I see it. You initialize deb to true, and your debounce condition is if not deb then so that’s also evaluating not true → false. Swap all your debounces, so the initial value is deb == false, your conditional is still if not deb then but inside your code you set deb = true, run your code, then deb = false when finished.
instead of if clicks.Value >= price do if clicks.Value >= price and debounce == false
set debounce back to false inside that clicks value function, like
set debounce to false when defining it first time debounce = true -> debounce = false
if clicks.Value >= price and debounce == false then
task.delay(0.5, function()
debounce = false
end)
end
try if this works
local price = script.Parent.price.Value -- instead of using intvalues, you can also use attributes
local debounce = false
script.Parent.Touched:Connect(function(toucher)
if debounce then return end
if not game.Players:GetPlayerFromCharacter(toucher.Parent) then return end
if player.leaderstats.Clicks.Value >= price then
player.leaderstats.Clicks.Value -= 50
task.delay(0.5, function()
debounce = false
end)
end
end)