I'm making a stamina intvalue so when you swing a sword it subtracts a certain amount of stamina from the value. This is a local script under the sword tool.
script.Parent.Activated:Connect(function() Stamina = Stamina - 30 wait(.9) print(Stamina) end)
It says -30 in the output. Why does this happen?
That Stamina Int Value must be equal to 0. Thats why It's being substracted, if not Your probably doing something client side and server side. which aren't supposed to be happening.
I'm assuming that its appearing as -30 because in the server it's (The actual number of the value) but your substracting it in the client. So you'll have to substract in the server:
Local Script
local Remote = Instance.new("RemoteEvent") Remote.Parent = game.ReplicatedStorage script.Parent.Activated:Connect(function() Remote:FireServer(Stamina) wait(.9) print(Stamina) end)
Server Script
game.ReplicatedSotrage.OnServerEvent:Connect(function(Player,Stamina) Stamina = Stamina - 30 end)
There may be some problems and you'll need to adjust it to work with your script.
Put the server script inside of serverscriptservice