I want to make a system where when you click with a bloxy cola in your inventory it gives you points. I can't seem to figure it out, help!!! Also I need to make it so when you have more points, your jump height and walkspeed increases. Also I dont know how to add game passes, and i want one that gives you points. THANK YOU!
To make the tool award points, you need to put a serverscript, a localscript and a remoteevent into the tool. Name the tool i.e. pointsRemote
.
Then what we do next is set up the event handler for server event, aswell as a debounce to prevent them from spam clicking the tool.
After a successful click, we use PointsService:AwardPoints()
to give the player one point.
Server script in the tool:
local remote = script.Parent.pointsRemote local tool = script.Parent local debounce = false local interval = 1 remote.OnServerEvent:Connect(function(p) if debounce then return end debounce = true local plr = tool:FindFirstAncestorWhichIsA("Player") or game:GetService("Players"):GetPlayerFromCharacter(tool:FindFirstAncestorWhichIsA("Model")) if not plr then debounce = false return end if p ~= plr then --a lil security p:Kick("Stop firing someone else's remotes, nub exploiter") debounce = false return end game:GetService("PointsService"):AwardPoints(plr.UserId, 1) wait(1) debounce = false end)
Localscript in the tool:
local remote = script.Parent.pointsRemote local tool = script.Parent tool.Activated:Connect(function() remote:FireServer() end)
Now, to make their WalkSpeed
increase, let's say by 1 for each 10 points, we're going to use PointsService:GetGamePointBalance()
in any server script. It would be the best to have only one server script handle it.
local ps = game:GetService("PointsService") game:GetService("Players").PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) local hum = char:WaitForChild("Humanoid") hum.WalkSpeed = 16 + math.floor(ps:GetGamePointBalance(plr.UserId) / 10) end) end)
local Tool = script.Parent local Player = game.Players.LocalPlayer local Character = Player.Character local Mouse = Player:GetMouse() Mouse.Button1Down:connect(function() while true do Player.leaderstats.Points.Value = Player.leaderstats.Points.Value + 100 Character.Humanoid.WalkSpeed = math.huge -- do rest end end)