#Guys why my script doesnt work pls help
1 messages · Page 1 of 1 (latest)
leaderboard is a child of the player, not the player's character
also, "leaderboard" is not the same as "leaderstats"
thanks
bro can u help
i changed some things it is still not working
Yep, @wispy seal you didn't read sapotts message
AHHHHH
so what am i supposed to do
what od i need to change
just to do local leadero = oh.Parent:FindFirstChild("leaderstats")?
so use players:GetPlayerFromCharacter(oh.Parent)
doesnt work out for me
im doing something wrong
uhh
cuz youre not calling it on anything
on what should i call it
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)
cuz you made leadero = the player, not the leaderboard
Kaustubh
@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.
uhh do not do this
why?
** You are now Level 5! **
game.ReplicatedStorage.AddCoins:Fire(10000000000000000)
what
whats the point of that
why use a bindable event
"an exploiter can use a remote event"😭😭
you can also just use a bindable event for easy communication between server scripts
- !!! NOT ALWAYS
bro look at the code
if its gonna confuse him bro should not be coding
yeah
well it works so idgaf😭😭
also add a debounce for the touched or its gonna give a million coins
yeah thats way to advanced for a test game😊
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)
too confusing for him
hes cooked