Hi, so I was wondering, for my basketball game, to add player points. And for every shot they would make, they would get a specific amount depending on how far they were. In this case, if they were at least 59 studs away, they would receive 3 Player Points. If they were closer, they would receive 2 Player Points. Is there anyway to do that according to these two scripts?
Also could you revise this for me, hehe thanks (unless it's already good.)
local User = nil; local debounce = false local PointsService = game:GetService("PointsService") script.Parent.Touched:connect(function(hit) if not debounce then debounce = true if hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) local look = hit.Parent:findFirstChild("BallHandler").Value local found = game.Players:findFirstChild(look) local cash = found:findFirstChild("leaderstats") cash['Shots Made'].Value = cash['Shots Made'].Value+1 --this is the in-game leaderboard, not the player points print("Gave +1 SM") wait(1) PointsService:AwardPoints(plr.userId,1) --or possibly 2 or 3 end end end)
--So for this one, there are actually BoolValues inside the tool that will determine if it is three points or two points, but I was wondering if we could combine these two scripts in order to make one complete one.
Tool = script.Parent goal = workspace.BUILDING.COURT.game_Court.GAMEHoop.Goal --basically the part it will touch when it is shot dist = 59 --how far away the three point line is function fire(v) local vCharacter = Tool.Parent local torso = vCharacter:FindFirstChild("Torso") local vPlayer = game.Players:playerFromCharacter(vCharacter) local spawnPos = vCharacter.PrimaryPart.Position spawnPos = spawnPos + (v * 5) connection:disconnect() wait() Tool.Parent = game.Workspace Tool.Handle.Position = spawnPos Tool.Handle.Velocity = (v * Tool.PowerValue.Value)+Vector3.new(0,50,0) -- this is just when the basketball is released if ((goal.Position - torso.Position).magnitude > dist) then Tool.three.Value = true --bool value else Tool.three.Value = false end end -- this part has nothing to do, i think function onActivated() local character = Tool.Parent; local humanoid = character.Humanoid if humanoid == nil then print("Humanoid not found") return end local targetPos = humanoid.TargetPoint local lookAt = (targetPos - character.Head.Position).unit fire(lookAt) end while true do script.Parent.Activated:wait() connection = game:service("RunService").Stepped:connect(onActivated) wait() end
Thanks for all the help you guys have done for me and the ROBLOX community! I really appreciate it.
Thanks, LukeGabrieI (also known as EnergyBrickz)