ultrameep Newbie
Joined: 01 Jul 2008 Posts: 4
|
Posted: Thu Jul 03, 2008 11:18 pm Post subject: |
|
|
probably not the best, but it works
---------------------------------------------------
local brick = script.Parent -- the brick it checks
local precision = 0.5 -- the lower the better, however it will lag more with a lower number
time = 10
function blah(player)
for i = 1,time/precision do
wait(precision)
if Inside[player.Name] ~= true then return end
end
script.Parent.TeamColor = player.TeamColor
script.Parent.BrickColor = player.TeamColor
end
Inside = {}
function isIn(part1,part2)
if part1.Position.x >= part2.Position.x - (part2.Size.x / 2) and part1.Position.x <= part2.Position.x + (part2.Size.x / 2) then
if part1.Position.y >= part2.Position.y + (part2.Size.y / 2) and part1.Position.y <= part2.Position.y + (part2.Size.y / 2) + 5 then
if part1.Position.z >= part2.Position.z - (part2.Size.z / 2) and part1.Position.z <= part2.Position.z + (part2.Size.z / 2) then
return true
end
end
end
return false
end
function onPlayerRemoving(player)
if Inside[player.Name] then
Inside[player.Name] = nil
end
end
game.Players.PlayerRemoving:connect(onPlayerRemoved)
while true do
local z = game.Players:GetChildren()
for i = 1,#z do
if z[i].Character then
if z[i].Character:findFirstChild("Torso") then
if isIn(z[i].Character.Torso,brick) then
if not Inside[z[i].Name] then
coroutine.resume(coroutine.create(blah),z[i])
Inside[z[i].Name] = true
end
else
if Inside[z[i].Name] then
Inside[z[i].Name] = nil
end
end
end
end
end
wait(precision)
end |
|