Is it possible to script so when you upgrade you do 2x damage then normal?

  1. What do you want to achieve? So when you upgrade as a player only 1 player you have 2x damage then regular

this is the output

  1. What solutions have you tried so far? So luis a web dev helped alot but i forgot to add something else

Im making a game when you punch something you get Resources and if you get resources you can get upgrades and if you get upgrades you get 2x damage then normal im trying to script it but im very new to scripting so yea.

local click = script.Parent.ClickDetector
local value = script.Parent.Value
wait(.00000000000000001)
local damage = game.Players:GetChildren("Value")

click.MouseClick:Connect(function(player)
	
	local resources = player:WaitForChild("leaderstats"):WaitForChild("Resources")
	value.Value += 1
	
	if damage.Value >= 1 then
		value.Value += 1
	
	if value.Value >= 5  then
		script.Parent.Transparency = 1
		script.Parent.CanCollide = false
	if value.Value == 5 then
		script.Parent.Transparency = 1
		script.Parent.CanCollide = false
		resources.Value += 1
		wait(10)
		script.Parent.Transparency = 0
		script.Parent.CanCollide = false
				value.Value = 0
			end
		end
	end
end)

Idk if this is against the tos of the devforum but please help

wait(.00000000000000001) is such an infinitesimally small number it shouldn’t be there. :GetChildren() also accepts no parameters, perhaps you meant game.Players:WaitForChild("Value")?

You’d need to address the architecture of the game to achieve what you want. Each player should house their own damage value; it looks like you’re referencing a singular value for everyone. Not sure what script.Parent is referencing but it looks like a tree you punch? Each tree should be handled by a script/module script in ServerScriptService, and have that script handle the players’ damage and resources, to keep such values from being exposed to exploiters.

i kinda dont care for exploiters i mean theyll ruin the game for everyone but idrc i just dont know how to do that im new to scripting

not a selfish person but why would they hack my game
bedwars easily hacked any pvp game is a downfall but simulators or somethin no

1 Like
local part = script.Parent
local click = part.ClickDetector
local value = part.Value

local players = game:GetService("Players")
local damage = players:GetChildren("Value") --Does this even exist? Parenting instances to the players service is unusual.

click.MouseClick:Connect(function(player)
	value.Value += 1

	if damage.Value >= 1 then
		value.Value += 1
	end

	if value.Value >= 5 then
		value.Value = 0
		part.Transparency = 1
		part.CanCollide = false
		player.leaderstats.Resources.Value += 1
		task.wait(10)
		part.Transparency = 0
		part.CanCollide = true
	end
end)

Yes i made a instance In the player Called Just “Value”

I just realized it’s wrong anyway, you don’t pass arguments to “:GetChildren()” since it just returns an array of the instances children. Here’s the script with that part removed.

local part = script.Parent
local click = part.ClickDetector
local value = part.Value

click.MouseClick:Connect(function(player)
	value.Value += 1

	if value.Value >= 5 then
		value.Value = 0
		part.Transparency = 1
		part.CanCollide = false
		player.leaderstats.Resources.Value += 1
		task.wait(10)
		part.Transparency = 0
		part.CanCollide = true
	end
end)

Do you know how to put damage like when a player upgrades with resources then it gives like 2 damage to the object and im sorry if im asking for to much

I want a rebirth or damage system or both

So i noticed that when i rebirth and break a tree it instead gives me 25 instead of two so i need a damage system really

Btw may as well remove the rebirth system but i might find a way to fix it