#Guys why my script doesnt work pls help

1 messages · Page 1 of 1 (latest)

wispy seal
ebon root
#

leaderboard is a child of the player, not the player's character

dapper anvil
#

also, "leaderboard" is not the same as "leaderstats"

wispy seal
#

i changed some things it is still not working

dapper anvil
#

Yep, @wispy seal you didn't read sapotts message

wispy seal
#

so what am i supposed to do

#

what od i need to change

#

just to do local leadero = oh.Parent:FindFirstChild("leaderstats")?

ebon root
#

getplayerfromcharacter

#

player is not a direct parent of character

#

workspace is

wispy seal
#

oh

#

i didnt learn that yet

ebon root
#

so use players:GetPlayerFromCharacter(oh.Parent)

wispy seal
#

im doing something wrong

#

uhh

ebon root
#

cuz youre not calling it on anything

wispy seal
#

on what should i call it

ebon root
#

gpfc is a method of the playerservice

#

so you tell the code

#

hi im referencing the playerservice. game, can u use the playerservice function gpfc on this part?

#

by typing game.Players:GetPlayerFromCharacter(oh.Parent)

wispy seal
#

okay ima try

#

lol im so bad at roblox studio

ebon root
#

cuz you made leadero = the player, not the leaderboard

mystic wasp
#

Kaustubh

next hedge
#

@wispy seal I can help

#

hold on let me recreate this in my test game

#

so I have a very simple leaderboard script

game.Players.PlayerAdded:Connect(function(plr)
    local leaderstats = Instance.new("Folder", plr)
    leaderstats.Name = "leaderstats"
    local coins= Instance.new("IntValue", leaderstats)
    coins.Value = 0
    coins.Name = "Coins"
    
end)```
#

Next, add a BindableEvent into ReplicatedStorage and change the leaderstats code to this:

local leaderstats
local coins
game.Players.PlayerAdded:Connect(function(plr)
    leaderstats = Instance.new("Folder", plr)
    leaderstats.Name = "leaderstats"
    coins= Instance.new("IntValue", leaderstats)
    coins.Value = 0
    coins.Name = "Coins"
    
end)

game.ReplicatedStorage.AddCoins.Event:Connect(function(x)
    coins.Value = coins.Value + x
end)```
#

on the part, add a serverscript with this code:

local pr = script.Parent
pr.Touched:Connect(function(other)
    local hum = other.Parent:FindFirstChild("Humanoid")
    if hum then
        game.ReplicatedStorage.AddCoins:Fire(1)
    end
end)```
#

and you have your finished product :)

#

ofc if you are using this for like a simulator or a game then you want a delay, all you need is a simple task.wait

local pr = script.Parent
pr.Touched:Connect(function(other)
    local hum = other.Parent:FindFirstChild("Humanoid")
    if hum then
        task.wait(1)
        game.ReplicatedStorage.AddCoins:Fire(1)
    end
end)```
#

the reason it is so fast is because the roblox player is made up of so many parts.

ebon root
#

uhh do not do this

next hedge
hearty sealBOT
#

studio** You are now Level 5! **studio

ebon root
#

game.ReplicatedStorage.AddCoins:Fire(10000000000000000)

next hedge
#

whats the point of that

ebon root
#

why use a bindable event

next hedge
#

"an exploiter can use a remote event"😭😭

#

you can also just use a bindable event for easy communication between server scripts

ebon root
#

guy doesnt know how to get the player

#

its just gonna confuse him

next hedge
next hedge
#

if its gonna confuse him bro should not be coding

ebon root
next hedge
#

well it works so idgaf😭😭

ebon root
#

also add a debounce for the touched or its gonna give a million coins

next hedge
#

yeah thats way to advanced for a test game😊

ebon root
#
local pr = script.Parent
local touched = {}
pr.Touched:Connect(function(other)
    local hum = other.Parent:FindFirstChild("Humanoid")
    if hum then
        local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
        if plr and not table.find(touched, plr) then
          table.insert(touched, plr)
          game.ReplicatedStorage.AddCoins:Fire(1)
          task.delay(1, function()
          table.remove(touched, table.find(touched, plr))
          end)
        end
    end
end)
ebon root
#

hes cooked

next hedge
#

lmao

#

where da show off channel;

#

i got a crazy game

#

... well not that crazy