Speeding Wall Script
thaiballs!
0:00 / 0:00
Speeding Wall Script
204 просмотра · 10 дней назад
thaiballs!
44 подписчика
204 просмотра · 10 дней назад
script:
local model = script.Parent
-- Reference the parts
local buttonPart = model:WaitForChild("BUTTONPART")
local wallPart = model:WaitForChild("WALLPART")
-- Configuration: Speed, Duration, and Custom Images
local MOVE_SPEED = 20 -- Studs per second
local MOVE_DURATION = 3 -- How long it moves forward in seconds
local COOLDOWN = 1 -- Pause before resetting
-- Paste your Image Asset IDs here (e.g., "rbxassetid://12345678")
local YELLOW_IMAGE_ID = "" -- Image for Idle (Yellow) state
local RED_IMAGE_ID = "" -- Image for Active (Red Killbrick) state
local IMAGE_FACE = Enum.NormalId.Front -- Options: Front, Back, Top, Bottom, Left, Right
-- Internal state tracking
local isBusy = false
local originalCFrame = wallPart.CFrame
-- Set up or find Decal on the wall
local wallDecal = wallPart:FindFirstChildOfClass("Decal")
if not wallDecal then
wallDecal = Instance.new("Decal")
wallDecal.Face = IMAGE_FACE
wallDecal.Parent = wallPart
end
-- Function to set visual appearance
local function setWallVisuals(color, imageId)
wallPart.Color = color
wallDecal.Texture = imageId
end
-- Initial state setups
setWallVisuals(Color3.fromRGB(255, 255, 0), YELLOW_IMAGE_ID) -- Yellow (Idle)
buttonPart.Color = Color3.fromRGB(0, 255, 0) -- Green (Ready)
-- Create a ClickDetector on the button if missing
local clickDetector = buttonPart:FindFirstChildOfClass("ClickDetector")
if not clickDetector then
clickDetector = Instance.new("ClickDetector")
clickDetector.MaxActivationDistance = 32
clickDetector.Parent = buttonPart
end
-- Killbrick touch handler
local touchConnection
local function enableKillbrick()
touchConnection = wallPart.Touched:Connect(function(hit)
if not isBusy then return end
local character = hit.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.Health = 0
end
end)
end
local function disableKillbrick()
if touchConnection then
touchConnection:Disconnect()
touchConnection = nil
end
end
-- Button click event
clickDetector.MouseClick:Connect(function(player)
if isBusy then return end
isBusy = true
-- Update colors and change to Red Image
buttonPart.Color = Color3.fromRGB(255, 0, 0)
setWallVisuals(Color3.fromRGB(255, 0, 0), RED_IMAGE_ID)
enableKillbrick()
-- Calculate forward path strictly based on the wall's front vector
local startPosition = wallPart.Position
local targetPosition = startPosition + (wallPart.CFrame.LookVector * (MOVE_SPEED * MOVE_DURATION))
local tweenService = game:GetService("TweenService")
local moveInfo = TweenInfo.new(MOVE_DURATION, Enum.EasingStyle.Linear)
-- Move Forward
local moveForwardTween = tweenService:Create(wallPart, moveInfo, {CFrame = CFrame.new(targetPosition) * wallPart.CFrame.Rotation})
moveForwardTween:Play()
moveForwardTween.Completed:Wait()
-- Return to Original Spot
local moveBackTween = tweenService:Create(wallPart, moveInfo, {CFrame = originalCFrame})
moveBackTween:Play()
moveBackTween.Completed:Wait()
-- Reset Wall visual and Button state
disableKillbrick()
task.wait(COOLDOWN)
setWallVisuals(Color3.fromRGB(255, 255, 0), YELLOW_IMAGE_ID)
buttonPart.Color = Color3.fromRGB(0, 255, 0)
isBusy = false
end)