-
What do you want to achieve? Keep it simple and clear!
So currently i’m working on anti-steal system of ores, if one player already hit it, other can’t do it -
What is the issue? Include screenshots / videos if possible!
Idk how to do that - What solutions have you tried so far? Did you look for solutions on the Developer Hub? I tryed to use value for it. but when i change value to other person, i still can mine it
Here is code:
local Rock = script.Parent
local SettingsUI = Rock.Settings
local OreDrop = game:GetService("ReplicatedStorage").OreThings.Coal
local swingsLeft = 15
local TweenService = game:GetService("TweenService")
local RegenerateTimer = 10
local OreDropped = false
local OwnerVal = script.Parent.OwnerVal
local function Regenerate()
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
local Goal = {Size = Vector3.new(4,2,4)}
local tweenInfo2 = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
local Goal2 = {Size = Vector3.new(4,2,4)}
local Tween = TweenService:Create(Rock, tweenInfo, Goal)
local Tween2 = TweenService:Create(Rock.Parent.Union, tweenInfo2, Goal2)
Tween:Play()
Tween2:Play()
while RegenerateTimer > 0 do
SettingsUI.Frame.OreName.TextLabel.Text = "REGENERATING: "..RegenerateTimer.."s"
RegenerateTimer -= 1
wait(1)
end
if RegenerateTimer == 0 then
local tweenInfo1 = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
local Goal1 = {Size = Vector3.new(6.3, 3.15, 6.3)}
local tweenInfo3 = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
local Goal3 = {Size = Vector3.new(3.5, 6.5, 6.4)}
local Tween1 = TweenService:Create(Rock, tweenInfo1, Goal1)
local Tween3 = TweenService:Create(Rock.Parent.Union, tweenInfo3, Goal3)
Tween1:Play()
Tween3:Play()
swingsLeft = 15
OreDropped = false
SettingsUI.Frame.HealthFrame.Frame.Frame:TweenSize(UDim2.new(0.98,0,1,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1, true)
SettingsUI.Frame.OreName.TextLabel.Text = "Coal Ore ("..swingsLeft.."/15)"
RegenerateTimer = 10
end
end
local function onTouch(otherPart)
local tool = otherPart.Parent
if tool:IsA('Tool') and tool.Mining.Value == true then
if swingsLeft > 0 then
if OwnerVal.Value == tool.Parent.Name or "" then --Anti Steal System
OwnerVal.Value = tool.Parent.Name --Anti Steal System
print("Player is owner") --Anti Steal System
if tool.Name == "OwnerPickaxe" then
swingsLeft -=15
tool.Mining.Value = false
SettingsUI.Frame.OreName.TextLabel.Text = "Coal Ore ("..swingsLeft.."/15)"
SettingsUI.Frame.HealthFrame.Frame.Frame:TweenSize(UDim2.new(swingsLeft/15,0,1,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1, true)
else
swingsLeft -= 1
tool.Mining.Value = false
SettingsUI.Frame.OreName.TextLabel.Text = "Coal Ore ("..swingsLeft.."/15)"
SettingsUI.Frame.HealthFrame.Frame.Frame:TweenSize(UDim2.new(swingsLeft/15,0,1,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1, true)
end
end
end
if swingsLeft <= 0 then
if OreDropped == false then
OreDropped = true
local OreDropClone = OreDrop:Clone()
local NewY = Rock.Position.Y + 5
OreDropClone.Position = Vector3.new(Rock.Position.X,NewY,Rock.Position.Z)
OreDropClone.Parent = workspace
Regenerate()
end
end
end
end
Rock.Touched:Connect(onTouch)