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

How To Make Dropped Cash Only Can Claimed By Other Player?

Asked by 2 years ago

Sorry For Bad English, I Am Making Script That When You Triggered Prompt, You Will Get Billboard Gui With "Wanted" Text On Head, And Need To Hide Until 100 Seconds Pass To Get Money, And If You Dies, You Drop The Money That You Got From Robbery, And Other Player Can Claim It But Problem Is That I Can Claim It too, And I Want Only Other Player Can Claim It, Can Someone Advice Me?, I'm Begginer To Scripting!

Cash Script

01local money = script.Parent.Parent
02local clickDetector = money.ClickDetector
03 
04clickDetector.MouseClick:Connect(function(plr)
05 
06    local cash = plr.leaderstats.Gold
07    local amountValue = money.BillboardGui.amountOfCash
08    cash.Value += amountValue.Value
09 
10    money:Destroy()
11 
12 
13end)

Proximity Prompt Script

01local db = true
02local script1 = game.Lighting.RobberyCashDrop.CashDrop
03local gui = game.Lighting.RobberyCashDrop.WantedGUI
04 
05script.Parent.Triggered:Connect(function(plr)
06    local Character = plr.Character or plr.CharacterAdded:Wait()
07    if db == true then
08        db = false
09        local a = script1:Clone()
10        a.Parent = Character
11        local b = gui:Clone()
12        b.Parent = Character:FindFirstChild("Head")
13        wait(100)
14        plr.leaderstats.Gold.Value = plr.leaderstats.Gold.Value + 250
15        a:Destroy()
View all 33 lines...

Cash Drop Script

01local char = script.Parent
02local human = char:WaitForChild("Humanoid")
03local humanRoot = char:WaitForChild("HumanoidRootPart")
04local cash = game.Lighting.RobberyCashDrop:WaitForChild("Cash")
05local PlayerService = game:GetService("Players")
06 
07human.Died:Connect(function()
08    local playerFromCharacter = PlayerService:GetPlayerFromCharacter(human.Parent)
09    local moneyDropped = 250
10    local cashClone = cash:Clone()
11    cashClone.BillboardGui.amountOfCash.Value = moneyDropped
12    cashClone.BillboardGui.amount.Text = "$" .. tostring(moneyDropped)
13 
14    cashClone.Parent = game.Workspace
15 
16    cashClone.CFrame = humanRoot.CFrame + (humanRoot.CFrame.LookVector * Vector3.new(2,2,2))
17end)

1 answer

Log in to vote
1
Answered by 2 years ago

You just make an int value that holds the user id so that you can check who the owner is.

Drop Cash Script:

01local char = script.Parent
02local human = char:WaitForChild("Humanoid")
03local humanRoot = char:WaitForChild("HumanoidRootPart")
04local cash = game.Lighting.RobberyCashDrop:WaitForChild("Cash")
05local PlayerService = game:GetService("Players")
06 
07human.Died:Connect(function()
08    local playerFromCharacter = PlayerService:GetPlayerFromCharacter(human.Parent)
09    local moneyDropped = 250
10    local cashClone = cash:Clone()
11    cashClone.BillboardGui.amountOfCash.Value = moneyDropped
12    cashClone.BillboardGui.amount.Text = "$" .. tostring(moneyDropped)
13 
14 
15    local val = Instance.new("IntValue")
View all 22 lines...

Cash Script:

01local money = script.Parent.Parent
02local clickDetector = money.ClickDetector
03 
04clickDetector.MouseClick:Connect(function(plr)
05    if plr.UserId ~= money.IntValue.Value then
06    local cash = plr.leaderstats.Gold
07    local amountValue = money.BillboardGui.amountOfCash
08    cash.Value += amountValue.Value
09 
10    money:Destroy()
11    end
12 
13end)

Hope you understand what I did and I hope that this helps :)

0
Name the IntValue too in case if there are two or more children named "IntValue" in cashClone T3_MasterGamer 2189 — 2y
Ad

Answer this question