of     1   

Raildex
#182583920Friday, January 29, 2016 12:54 AM GMT

how do you run a script so that every second if the player is touching part then add money. The way I'm currently doing it, it only activates when they first touch the part and not while they are touching it.
SwagCuzYolo
#182584113Friday, January 29, 2016 12:57 AM GMT

Touching = false part.Touched:connect(function() Touching = true while Touching do GiveMoney() wait() end end) part.TouchEnded:connect(function() Touching = false end) This is more of an idea of how it would work. Realistically you would want to make a table of all players touching the brick and remove them from the table when they stop touching. This will not work if more than one player is involved.
Raildex
#182584520Friday, January 29, 2016 1:03 AM GMT

local takeWait = 0 function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if (h~=nil) then print("Player touched") local teamColor = script.Parent.Parent.Parent.teamColor if game.Players:playerFromCharacter(h.Parent).TeamColor~=BrickColor.new(teamColor.Value)then --If the one who pressed the button is on the team then print("is homeTeam") local thisplr = game.Players:findFirstChild(h.Parent.Name) if (thisplr~=nil) then local stats = thisplr:findFirstChild("leaderstats") if (stats~=nil)then takeWait = 1 while takeWait==1 do local score = stats:findFirstChild("Resources") local cash = stats:findFirstChild("Cash") score.Value = score.Value + 10 script.Parent.Parent.Parent.Resources.Value = script.Parent.Parent.Parent.Resources.Value - 10 cash.Value = cash.Value + 1 wait(2) end takeWait = 0 end end end end end script.Parent.Touched:connect(onTouched) This is what I have for it so far, how is TouchEnded called in your example script? What else do I need here to make it work

    of     1