Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make it so when i click with an item, it rewards points?

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!

3 comments

0

It would have to be a "custom" Bloxy Cola and not directly from Roblox. Plus, SH is not a request site.

0

im just asking...? also if this isnt what is a good site to do that

0

Well a pro-tip would be; Read the rules to a forum before posting. "No requests" is plastered all over here.

2 answers

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)

13 comments

0

Jesus christ

0

lol

0

how do you put a server script in the tool?

0

Create one under the tool in studio. Right click the tool > Insert Object > Script

0

im sorry for being stupid but are you talking about the bloxy cola tool?

0

Lovely script, please don't feed into requesters though.

0

Yes, im talking about the bloxy cola tool

0

then do we add anything into the remoteevent?

0

It says this : PointsService:GetUserPointBalanceInUniverse failed because PointsService:GetUserPointBalanceInUniverse failed because Non-API Proxy BaseURL used. HttpRbxApiService is only for API Proxy calls. And this : pointsRemote is not a valid member of Tool

0

You need to create the pointsRemote under the tool aswell. Right Click > Insert Object > RemoteEvent > rename to pointsRemote

0

as for the pointsservice error, it could be due to the fact that you test in studio

0

is a server script just a script?

0

@PikaPeedy yes it is

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)

2 comments

0

MouseButton1Down isn't an event of a tool

1

Now it wouldn't be FE compatible, would fire even if the tool isn't equipped, and would always set the WalkSpeed to math.huge no matter how many points they have

This discussion is preserved as it was. New answers, comments, and votes are closed.