local ting = 0 --debouncer local mon = script.Parent.Parent.MoneyValue minstilregen = 2 -- change this to how ever many mins you want it to take before you can use again tt = minstilregen * 60-- dont change function onTouched(hit) if ting == 0 then --debounce check ting = 1 --activate debounce check = hit.Parent:FindFirstChild("Humanoid") --Find the human that touched the button if check ~= nil then --If a human is found, then local user = game.Players:GetPlayerFromCharacter(hit.Parent) --get player from touching human local stats = user:findFirstChild("leaderstats") --Find moneyholder if stats ~= nil then --If moneyholder exists then local cash = stats:findFirstChild("Money") --Get money cash.Value = cash.Value + mon.Value script.Parent.Parent.Name = "Fixed" -- you should change this also script.Parent.Transparency = 0.8 wait(tt)-- do not change script.Parent.Parent.Name = "Pay amount: 100" -- change this to the title you want script.Parent.Transparency = 0.2 end end ting = 0 --remove debounce end end script.Parent.Touched:connect(onTouched)
I want to give players of specific teams blocks to touch to gain money but I also don't want players of other teams to come in and touch the bricks for the money. I have a script that will give money on touch and it has a timer to ensure no spam but I can't find where to put the check team part of the script and when I try it will end up breaking most of the script. Any help would be appreciated! So just to clarify I need help adding into my current script a part that checks the humanoid that touched the part's team to make sure that everyone has a fair advantage this is my old script ive got a newer one but i still cant figure out what im doing wrong
-- something like -- script should be in the part that is to be touched script.Parent.Touched:Connect(function(hit) if hit.Parent.Humanoid then if hit.Parent.Name == game.Players.LocalPlayer.Name and game.Players.LocalPlayer.Team == "Name of the team" then -- what you want the script to do because I don't know how your currency script works wait(5) -- the number of seconds you want player to wait before getting money again end end end) -- hope it helps
--leaderboard script function onPlayerEntered(newplayer) local stats = Instance.new("IntValue") stats.Name = "leaderstats" stats.Parent = newplayer local money = Instance.new("IntValue") money.Name = "Money" money.Value = 1000 money.Parent = stats local wood = Instance.new("IntValue") wood.Name = "Pts" wood.Value = 10 wood.Parent = stats end game.Players.ChildAdded:connect(onPlayerEntered)
minstilregen = 2 tt = minstilregen * 60 script.Parent.Touched:Connect(function (hit) if hit.Parent.Humanoid then if hit.Player.Name == game.Players.LocalPlayer.Name and game.Players.LocalPlayer.Team == "Factory" then local user = game.Players:GetPlayerFromCharacter(hit.Parent) local stats = user:findFirstChild("leaderstats") local mon = script.Parent.Parent.MoneyValue if stats ~= nil then local cash = stats:findFirstChild("Money") cash.Value = cash.Value + mon.Value script.Parent.Parent.Name = "Fixed" script.Parent.Transparency = 0.8 wait(tt) script.Parent.Parent.Name = "Pay amount: 100" script.Parent.Transparency = 0.2 end end end end)
this is my newer script and I know I'm missing something sorry I'm still new to this site and scripting in general
Ok, replying to FirezoneGamez, you should use his script but, he did it wrong, use this:
-- something like -- script should be in the part that is to be touched script.Parent.Touched:Connect(function(hit) if hit.Parent.Humanoid then if hit.Parent.Name == game.Players.LocalPlayer.Name and game.Players.LocalPlayer.TeamColor = BrickColor.new("COLORHERE") -- Replace 'COLORHERE' with the color of the team. -- what you want the script to do because I don't know how your currency script works wait(5) -- the number of seconds you want player to wait before getting money again -- Here is the script for the money, local points = Instance.new("IntValue") --Change points to whatever you want, unless you want to keep it points.Name = "Cash" --Name of the Points, or whatever name you changed it to points.Parent = leaderstats points.Value = "None" end end end) -- hope it helps