#why is my script not wokring?

1 messages · Page 1 of 1 (latest)

pastel bear
#
local rarityevent = game.ReplicatedStorage.Events.RarityEvent

players.PlayerAdded:Connect(function(plr)
    local ls = Instance.new("Folder", plr)
    ls.Name = "leaderstats"
    local cash = Instance.new("IntValue", ls)
    cash.Name = "Cash"
    cash.Value = 250
    
    local stars = Instance.new("IntValue", ls)
    stars.Name = "Stars"
    stars.Value = 0
    
    local totalratings = Instance.new("IntValue", plr)
    totalratings.Name = "totalratings"
    totalratings.Value = 0
end)


rarityevent.Event:Connect(function(plr, rarity)
    plr:WaitForChild("totalratings").Value += 1
    
    local currentStars = plr.leaderstats.Stars.Value / plr.totalratings.Value
    plr.leaderstats.Stars.Value = math.floor(currentStars)
end)
#

please ping me if you reply, thanks!

#

i will try this right now, thank you so much!

bold drift
pastel bear
#

i will

#

"attempt to indez nil with WaitForChild"

bold drift
#

oh i see the issue i think

#

let me fix it

pastel bear
#

alr thanks

bold drift
#

try that now

pastel bear
#

same thing

bold drift
#

i think i might be dumb

#

let me re read

#

😭

#

doing this on phone isnt fun

pastel bear
#

understandable

#

attempt indez nil with findfirstchild

bold drift
#

wait so something is parented wrong

#

wait why is total rating parented to the plr

pastel bear
#

i dont want it to be a leaderstat

#

its just to calculate the stars

bold drift
#

fair enough

pastel bear
#

wait

#

let me see something

#

its in this function so i think thats why it doesnt work since plr isnt used correctly: ```local function getfoodinInventory(plr)
if isTaken == false then
local chosenfood, rarityKey = moduletable.ChooseFood() --chosen food from the module script
if chosenfood then
wait(cooktime)
local visiblefood = food:FindFirstChild(chosenfood.Name) --finds the food inside of the food inside of the frying pan
for i, v in ipairs(visiblefood:GetChildren()) do
if v:IsA("BasePart") then
v.Transparency = 0
prox.ActionText = "Take"
currentfood = chosenfood
currentVisibleFood = visiblefood

                local rarity = tonumber(rarityKey)
                rarityEvent:Fire(plr, rarity)
                print(rarity)
            end
        end
    end
end

end

#

yeah that was the error

bold drift
#

ah

#

fair enough

#

all sorted then

#

?

pastel bear
#

yes now im rewriting the stars / totalratings since that didnt work

bold drift
#

fair

pastel bear
#

thank you for your time

bold drift
#

np

pastel bear
#

it works!

bold drift
#

awesome i shoudlve really asked what the error was from the start lol but glad it works