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

Tool/Handle Gives Points Rather Than Humanoid?

Asked by 8 years ago

Hello fellow ROBLOXian Scripters. I am in need of help, I am making a game that implements a Leaderboard consisting two things: XP and Levels. I was wondering instead of me touching the brick, is there a way a tool can touch it and give XP? It's for a basketball game.

01--Basically checks if the toucher of the button is a player, then adds money to that player.
02 
03local ting = 0 --debouncer
04 
05function onTouched(hit)
06 
07    if ting == 0 then --debounce check
08    ting = 1 --activate debounce
09    check = hit.Parent:FindFirstChild("Handle") --Find the human that touched the button
10 
11    if check ~= nil then --If a human is found, then
12 
13        local user = game.Players:GetPlayerFromCharacter(hit.Parent) --get player from touching human
14        local stats = user:findFirstChild("leaderstats") --Find moneyholder
15 
View all 29 lines...

Credit to Uberubert

Here's some extra code when left-clicking the basketball:

01Tool = script.Parent
02 
03function fire(v)
04    local vCharacter = Tool.Parent
05    local vPlayer = game.Players:playerFromCharacter(vCharacter)
06    local spawnPos = vCharacter.PrimaryPart.Position
07    spawnPos  = spawnPos + (v * 5)
08    connection:disconnect()
09    wait()
10    Tool.BallShadow.Disabled = false
11    Tool.Parent = game.Workspace
12    Tool.Handle.Position = spawnPos
13    Tool.Handle.Velocity = (v * Tool.Power.Value)+Vector3.new(0,50,0)
14end
15 
View all 32 lines...

Video: https://www.youtube.com/watch?v=ErSN1PHk4O8

-LukeGabrieI

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

Here you go sir made officially by Resplendid 100%

The Brick is:

01--Made 100% by Resplendid
02--For LukeGabriel
03function onTouch(hit)
04local look = hit.Parent:findFirstChild("BallHandler").Value
05    local found = game.Players:findFirstChild(look)
06    local cash = found:findFirstChild("leaderstats")
07    cash.XP.Value = cash.XP.Value+1000
08    print("Gave +1000 XP")
09end
10script.Parent.Touched:connect(onTouch)
11 
12 
13and the leaderstats in workspace by itself:
14 
15--Made 100% by Resplendid
View all 25 lines...

Also there needs to be a IntValue inside of the ball called "BallHandler" with a script of:

1while wait() do
2    plr=game.Players:FindFirstChild(script.Parent.Parent.Parent.Name)
3    if plr then
4        script.Parent.Value=plr.Name
5    end
6end

Here you go! It worked for me and it should work for you. Also, give me credit for this work.

Thanks, Resplendid.

Ad

Answer this question