Hi everyone I’m currently working on an Ability Tool System and I only need 4 more abilities so rn I want that when a Tool is activated a part should appear and disappear for few seconds now I asked Chat GPT(IK he’s not good) and I got a Script from him so the reason why I got the Script from Chat GPT is because I want to let u know what I mean I have this LocalScript in the Tool and I also got a Part called “PlatformTemplate” in the Replicated Storage
local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local replicatedStorage = game:GetService("ReplicatedStorage")
local platformTemplate = replicatedStorage:WaitForChild("PlatformTemplate")
local function createPlatform()
local character = player.Character or player.CharacterAdded:Wait()
local platform = platformTemplate:Clone()
platform.Position = character.HumanoidRootPart.Position + Vector3.new(0, 5, 0) -- Adjust height as needed
platform.Parent = workspace
-- Platform disappears after a few seconds
wait(5) -- Change duration as needed
platform:Destroy()
end
tool.Activated:Connect(createPlatform)
um I can’t exactly show a vid cuz im not finding any so I want to let a part appear where I click with my mouse when the Tool is activated and it should stay for 5 seconds and reset with a cooldown like when you place blocks in Minecraft
Give this function a try. You will have to add a range limit later on though. As for adding a cooldown afterwards, it’s as simple as adding a debounce:
local debounce = true -- While this value is true the platform can be created
local function createPlatform()
if not debounce then
return
end
debounce = false -- Can't use the platform again until this changes back to true
local platform = platformTemplate:Clone()
platform.Position = mouse.Hit.p -- Positions the platform where you clicked
platform.Parent = workspace
task.wait(5)
platform:Destroy()
task.delay(4, function() -- Adjust the number here for the cooldown length
debounce = true
end)
end