Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
imKlevi 94
5 years ago
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) ?

0
It prints 0 because in your comments you said that the damage is 0. hiimgoodpack 2009 — 5y
0
@hiimgoodpack Incorrect. They set another value at line 11, which is Damagecandeal, which is starterdamage*stats iSpaceRBLX 31 — 5y

2 answers

Log in to vote
1
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago

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.

0
ty imKlevi 94 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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?

0
yea imKlevi 94 — 5y
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. ForeverBrown 356 — 5y
0
^ ESPECIALLY if you go on any site such as this one or StackOverflow or hire another developer. iSpaceRBLX 31 — 5y

Answer this question