I am making a script that causes a part to grow as long as you are standing on it.
The problem is whenever I stand still, it doesn’t grow; it only grows when I move.
Script
local C = script.Parent:GetChildren()
local E = false
for i = 1,#C do
if C[i].Name == "Tile" then
C[i].Touched:Connect(function()
if E == false then
print("Touched")
E = true
C[i].Size = Vector3.new(9, C[i].Size.Y + 1, 9)
wait(1)
E = false
end
end)
end
end
local C = script.Parent:GetChildren()
local E = false
for i = 1,#C do
C[i].Touched:Connect(function()
E = false
while E == false do
wait()
print("Touched")
C[i].TouchEnded:Connect(function()
E = true
end)
end
end)
end
You can simple use the BasePart:GetTouchingParts() method to find if it’s touching a tile. It would only work if the tiles can collide.
for _, limb in next, character:GetChildren() do
if limb:IsA("BasePart") then
for _, part in next, limb:GetTouchingParts() do
if part.Name == "Tile" then
print("player is touching", limb, part)
end
end
end
end
There are multiple ways to get the character. Some are by using player.Characater, another is using a remote event to pass the character argument or player arg so you can use player.Character, or you can use player added and character added.