Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you make a part pay the price?

local rc = 50000

local debounce = true script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.leaderstats.Money.Value >= rc then if debounce then debounce = false if plr.leaderstats.Money.Value < 20 then return end script.Parent.Transparency = 0.5 script.Parent.CanCollide = false if rc.Value <=rc then script.Parent.Transparency= 0.15 script.Parent.CanCollide = true end end end end end)

that is my script for making players be able to go threw but i need help making it take away money.

1 comment

0

Explain, you are being too vague and unconstructive.

1 answer

This should work! ( I know this is vague and basically just the script but i didnt really know how to answer the question without giving the script xD)

local debounce = false
local rc = 50000

script.Parent.Touched:Connect(function(hit)
	local hum = script.Parent:FindFirstChild("Humanoid")
	if hum then
		if debounce == false then
			debounce = true
			local player = game.Players:WaitForChild(hum.Parent.Name)
			player.leaderstats.Money.Value = player.leaderstats.Money.Value - rc
			
			script.Parent.Transparency = 0.5
			wait(0.5)
			script.Parent.Transparency = 0
			debounce = false
		else
			return
		end
	end
end)

1 comment

0

didn't work

This discussion is preserved as it was. New answers, comments, and votes are closed.