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 |