I am aware of that. But for starters, a simple .Touched is easier to understand and experiment with.
Also format code bc there are no (âendâ)'s in it
For yours chickhenen would you put that in server script service???
You need to have a leaderstat script needs to have a RemoveEvent that gets fired everytime a player clicks/touches a button.
FireEvent
with the leaderstat script you should add
if âscript hereâ
then
leaderstat.Coins.Value + 1
The first script would be in server script storage. The second would be in any part you want to give you coins when you touch
âlocal Players = game:GetPlayers()â
this would not work as you need to get the players, so
game.Players would work better.
âLeaderStatsâ
after this you checked for (âif leaderstats thenâ) this would not work too because you need to call the name you just assigned it.
(âif LeaderStats thenâ)
At the very bottom it says Coins.Value = Coins.Value + 1
this can be simplified into Coins.Value += 1
Also add ends into the code
Thanks. I quickly made the script and I will apply your edits.
In the GUI youâll get your leaderboard stat of how much coins with the FireEvent.
so in server script service do i get rid of all the other scripts which accord to this.
I have modified the script to work because when I tested the script, it did not work. Make sure to put it under the part you want to be touched
Code:
local Players = game.Players
local part = script.parent
local db = true
part.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
if not db then return end
db = false
local Player = Players:GetPlayerFromCharacter(hit.Parent)
local LeaderStats = Player:FindFirstChild("leaderstats")
if LeaderStats then
local Coins = LeaderStats:WaitForChild("Coins")
Coins.Value += 1
task.wait(2)
db = true
end
end
end)
Yeah Thanks! Iâm on a vacation now so itâs kinda hard to type everything without being able to test it haha lol
Itâs ok! Yeah it is hard to type on phone lol that would be torture.
So the modified script have you condensed it into 1 script?
No, the first script I provided should be in server script storage. Here is it for convenience:
game.Players.PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = Player
local coins = Instance.new(âIntValueâ)
coins.Name = âCoinsâ
coins.Value = 0
coins.Parent = leaderstats
end)
Then his script should be added in any part you want that gives you a point every time you touch it.
Thank you i will try it thanks for your help!!!
Also if you have more than like 5 parts needed to be touched it would be easier to make 1 script to control them all. Making a script for every part is very bad, but if itâs 1 part needed then you should be fine.
Since the other guy is on phone the quotations are weird. I also had to change them, use âCoinsâ.
Wait nevermind, just do it yourself it doesnât work me mine either.
Yeah and adding to that, I updated the script in server script storage. (Just change all quotation marks to your own
The leaderstats thing was named folder so I just changed that aswell
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = 0
Coins.Parent = leaderstats
end)
Then:
local Players = game.Players
local part = script.parent
local db = true
part.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
if not db then return end
db = false
local Player = Players:GetPlayerFromCharacter(hit.Parent)
local LeaderStats = Player:FindFirstChild("leaderstats")
if LeaderStats then
local Coins = LeaderStats:WaitForChild("Coins")
Coins.Value += 1
task.wait(1)
db = true
end
end
end)
Everything should be fixed