Help with a script!

this is a script under the rock with a number value . this script:

local remote = game.ReplicatedStorage.MiningRemotes.Hit

remote.OnServerEvent:Connect(function(player, dur, mon)
	local durab = script.Parent.Durability.Value
	durab = durab - 1
	print(durab)
	print(player.Name)
end)

should take away 1 every time the remote is fired, which it takes away 1, once. it only stays at 1 no matter how many times its fired.

image

2 Likes

youre setting the value of durablity only to the durab variable so when you do:

its only gonna take away 1 from the variable, not the value

fixed script:

local remote = game.ReplicatedStorage.MiningRemotes.Hit

remote.OnServerEvent:Connect(function(player, dur, mon)
	local durab = script.Parent.Durability
	durab.Value -= 1 --// -= 1 is the same thing as (value = value - 1)
	print(durab.Value)
	print(player.Name)
end)
2 Likes

now it doesnt even print anything

like the script doesnt run at all or what, edited the script above so it prints the value

only printed my name the first time, but then the second time i did it it printed what ever the heck the text in blue is

ive fixed the script thanks to everyone for the help

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.