You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make a rock target move when hit and after a few hits, destroy it temporarily -
What is the issue? Include screenshots / videos if possible!
I can only make it so if it hits once, not multiple times, and it’s bugged -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried fiddling with my script so that It moves back and forth, but it doesn’t work.
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse() -- We need to get mouse (only in local script)
local Tool = script.Parent
local db = false
local ss = game.ReplicatedStorage["Small Stone"]
local bs = game.ReplicatedStorage["Big Stone"]
local startPosition = Vector3.new(-1, 0, 0)
local endPosition = Vector3.new(2, 0, 0)
Tool.Activated:Connect(function()
local Target = Mouse.Target
if Target then -- check if it exists
if Target.Name == "Rock" then -- checks the name
local Distance = (player.Character.HumanoidRootPart.Position-Target.Position).Magnitude
if Distance < 15 then -- Checks if plyer is close
if db == false then
db = true
wait(1)
ss:Clone().Parent = player:FindFirstChild("Backpack")
bs:Clone().Parent = player:FindFirstChild("Backpack")
ss:Clone().Parent = player:FindFirstChild("Backpack")
bs:Clone().Parent = player:FindFirstChild("Backpack")
Target.Position = startPosition
Target:MoveTo(startPosition)
wait(1)
Target.Position = endPosition
Target:MoveTo(endPosition)
Target.Parent.Parent = nil
wait(900)
Target.Parent.Parent = workspace
db = false
end
end
end
end
end)