im trying to make a script where if a player walks over a part, they get +1 gem. https://gyazo.com/9aae251d787379117dd8605db13d9dc8
this is my leaderboard script that i currently have: https://gyazo.com/9abcc6abbdc98ec2e2f791e7e32e1089
Hello, so make a script or something like that into the player, so into starterplayerscripts and do something like this:
playeradded connect to functin a = script.Parent.Pa(keep doing .parent until you reach the player).Character(player.Character is character) a.Touched:coonect(functkion(hit)--variable if hit.name = (name of gem so if name of part is "Gem" then do if hit . name == "Gem") so if hit.Name == "Gem" then gem:Destroy() a.Folderstats whateevr.Gems collected or whatever = a.Folderstats whatever.Gams collected + 1
Best way is to use a hit detection in the part handled by a server script (not local script):
local DB = false script.Parent.Touched:Connect(funtion(hit) local p = game.Players:GetPlayerFromCharacter(hit.Parent) if p then local stats = p:WaitForChild("leaderstats") local Gems = stats:WaitForChild("Gems") if DB == false then DB = true Gems.Value = Gems.Value + 1 --script.Parent:Destroy() --Only if you want it to be one time wait(1) DB = false end end end
and that should work. Its advised you set the gems value to something even if 0 when you create it in the leaderboard.