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

why value is still the same, when i do value * value please help me?

script.Parent.Events.DamageEvent.OnServerEvent:Connect(function(plr)
local damage = script.Parent.Damage --//Damage = 0 
local starterdamage = script.Parent.StarterDamage --//Damage = 4
local Level = game.ReplicatedStorage[plr.Name.."Data"].Level 
local Damagecandeal = game.ReplicatedStorage[plr.Name.."Data"].DamageCanDealByFruit --//Damagecandeal = 0
local Stats = game.ReplicatedStorage[plr.Name.."Data"].Stats --//Stats = 3 

while true do
	 wait(.1)
	 Damagecandeal.Value = starterdamage.Value * Stats.Value
	 damage.Value = Damagecandeal.Value
	 print(damage.Value)
         --//0 / the print
end
end)

it prints(0) ?

2 comments

0

It prints 0 because in your comments you said that the damage is 0.

0

@hiimgoodpack Incorrect. They set another value at line 11, which is Damagecandeal, which is starterdamage*stats

2 answers

✓ Accepted answer

we went over his code in DM and turns out it was an issue with how he was saving data. he forgot to save one of the values causing line 10 to multiply by zero.

if you have a similar problem, trace your steps. see if you changed the value anywhere. if you use datastore like op did, see if you're saving the data properly / where you're getting the value from in the first place.

1 comment

0

ty

Oh my god. Please learn some basic naming convention for Lua before scripting. This code is unbearable. Spacing is random, variable names' case is random, comments are basically nonexistent (apart from those that you put to indicate what the values should be). Please read this. It'll help.

For your question. Are you sure your values are set? Are you sure starterdamage.Value is 4 and Stats is 3?

3 comments

0

yea

1

To add to that(sorta)......you can make your code look however you want, however if you want other people to help you with the code (or are working with other people) you should follow conventions. Conventions are recommended though since they make the code easier to read in general.

0

^ ESPECIALLY if you go on any site such as this one or StackOverflow or hire another developer.

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