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

How to rob once per day NPC ? [closed]

Asked by
lenesulll -19
6 years ago

This question already has an answer here:

How to rob once per day when I am near of the NPC?

When I am near of a (shop assistant) NPC in my game If i have a weapon in my hand NPC to do a animation like hands up (I have already one animation) and if I don t have a weapon in my hand to can to buy from the shop And to can to rob just once per day if you stolled the shop at clock 14:30 to can to rob again tomorrow at 14:30 scripts:Money Giver

local debounce = false local playerfound = false

function CreateRegion3FromPart(Part) return Region3.new(Part.Position- (Part.Size/2) ,Part.Position+ (Part.Size/2)) end

function GetPlayersInPart(part) local region = CreateRegion3FromPart(part) local partsInRegion = workspace:FindPartsInRegion3(region,nil,math.huge) local players = { }

  for i,Part in pairs(partsInRegion) do
        local player = game.Players:GetPlayerFromCharacter(Part.Parent)
        if player then

              for i, v in pairs(players) do
                    if players[i].Name == player.Name then
                          playerfound = true
            end
        end   

        if playerfound == false then
              table.insert(players,player)
        end 
        playerfound = false 
    end
end

for i, v in pairs(players) do

     if players[i].Robbing.Value == false then
            game.ReplicatedStorage.ShowRobberyGUI:FireClient(players[i])
end
players[i].Robbing.Value = true
if players[i].CashCollected.Value < 3000 then
      players[i].CashCollected.Value = players[i].CashCollected.Value + 50
end

end return players end while wait(0.5) do GetPlayersInPart(game.Workspace.Detector) end

******(LocalScript) is in RobberyGui is in StarterGui******

game.ReplicatedStorage.ShowRobberyGUI.OnClientEvent:Connect(function() script.Parent.Frame.Visible = true end) game.ReplicatedStorage.HideRobberyGUI.OnClientEvent:Connect(function() script.Parent.Frame.Visible = false end)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ****(Local Script)is in CashCollected is in Frame is in RobberyGui in StarterGui*** +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

player = game.Players.LocalPlayer

script.Parent.Text = "$".. player:WaitForChild("CashCollected").Value

player:WaitForChild("CashCollected").Changed:Connect(function() script.Parent.Text = "$".. player:WaitForChild("CashCollected").Value end)

*****(Script) is in DoorDetector is in Workspace********

local debounce = false

script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.Robbing.Value == true then game.ReplicatedStorage.HideRobberyGUI:FireClient(player) player.leaderstats.Money.Value = player.leaderstats.Money.Value + player.CashCollected.Value player.CashCollected.Value = 0 player.Robbing.Value = false end end end)

(In ReplicatedStorage are 2 RemoteEvents) HideRobberyGUI and ShowRobberyGUI

***Detector is a part in workspace****

0
i think what you need to do is delete everything and start from scratch dareveloper 9 — 6y
0
You already asked this question and scriptinghelpers wants you to delete your old one if it isn't answered within 5 days (if you want to ask it again) https://scriptinghelpers.org/questions/57297/how-to-rob-once-per-day-when-i-am-near-of-the-npc User#20388 0 — 6y
0
3 days* User#20388 0 — 6y
0
easy, `if Day == NextDay then CanRob = true end` hellmatic 1523 — 6y
View all comments (3 more)
0
then after robbing set CanRob to false hellmatic 1523 — 6y
1
put the whole script in the code block lmao awesomeipod 607 — 6y
1
so messyy awesomeipod 607 — 6y

Marked as Duplicate by User#20388, Le_Teapots, theCJarmy7, Vulkarin, and lukeb50

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?