Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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!

0
It would have to be a "custom" Bloxy Cola and not directly from Roblox. Plus, SH is not a request site. DeceptiveCaster 3761 — 6y
0
im just asking...? also if this isnt what is a good site to do that PikaPeedy 3 — 6y
0
Well a pro-tip would be; Read the rules to a forum before posting. "No requests" is plastered all over here. Bellyrium 310 — 6y

2 answers

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

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)
0
Jesus christ MusicalDisplay 173 — 6y
0
lol awesomeipod 607 — 6y
0
how do you put a server script in the tool? PikaPeedy 3 — 6y
0
Create one under the tool in studio. Right click the tool > Insert Object > Script Amiaa16 3227 — 6y
View all comments (9 more)
0
im sorry for being stupid but are you talking about the bloxy cola tool? PikaPeedy 3 — 6y
0
Lovely script, please don't feed into requesters though. Bellyrium 310 — 6y
0
Yes, im talking about the bloxy cola tool Amiaa16 3227 — 6y
0
then do we add anything into the remoteevent? PikaPeedy 3 — 6y
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 PikaPeedy 3 — 6y
0
You need to create the pointsRemote under the tool aswell. Right Click > Insert Object > RemoteEvent > rename to pointsRemote Amiaa16 3227 — 6y
0
as for the pointsservice error, it could be due to the fact that you test in studio Amiaa16 3227 — 6y
0
is a server script just a script? PikaPeedy 3 — 6y
0
@PikaPeedy yes it is Yodadthin 2 — 3y
Ad
Log in to vote
-1
Answered by 6 years ago
Edited 6 years ago
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)
0
MouseButton1Down isn't an event of a tool Amiaa16 3227 — 6y
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 Amiaa16 3227 — 6y

Answer this question