So, here’s what I want it to do. So I want the Touch to turn into Clicking and I want it only Gamepass Owners can click. Here is the script.
model = script.Parent.Parent--Indicates that the script interacts with the model the button is grouped with.
backup = model:clone()
enabled = true
function regenerate()
model:remove()
wait(3)--
model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()
script.Disabled = true
script.Parent.BrickColor = BrickColor.new(26)--Black
wait(3)--Change this number to change the time in between regenerations via the button, in seconds..
script.Parent.BrickColor = BrickColor.new(104)--Purple
script.Disabled = false
end
function onHit(hit)
if (hit.Parent:FindFirstChild("Humanoid") ~= nil) and enabled then
regenerate()
end
end
script.Parent.Touched:connect(onHit)
for make a Own Gamepass you can put inside function onHit or regenrate
if you want it on onHit Function:
function onHit(hit)
if (hit.Parent:FindFirstChild(“Humanoid”) ~= nil) and enabled then
if game.MarketPlaceService:UserOwnsGamePassAsync(game.Players[hit.Parent.Name].UserId, GamePassId) then
regenerate()
else
print(“Player dont own the gamepass!”)
end
end
or if you want it on regenrate Function:
function regenerate()
if game.MarketPlaceService:UserOwnsGamePassAsync(game.Players[hit.Parent.Name].UserId, GamePassId) then
model:remove()
wait(3)--
model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()
script.Disabled = true
script.Parent.BrickColor = BrickColor.new(26)--Black
wait(3)--Change this number to change the time in between regenerations via the button, in seconds..
script.Parent.BrickColor = BrickColor.new(104)--Purple
script.Disabled = false
else
print(“Player dont own the gamepass!”)
end
end
or you can make it if not game.MarketPlaceService:UserOwnsGamePassAsync(game.Players[hit.Parent.Name].UserId, GamePassId) then return end
That function is deprecated so you should use Instance:Destroy() instead
model = script.Parent.Parent--Indicates that the script interacts with the model the button is grouped with.
local MarketplaceService = game:GetService("MarketplaceService")
local GamepassID = 0
backup = model:clone()
enabled = true
function regenerate(player)
if not MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then return end
if enabled then
model:Destroy()
wait(3)--
model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()
script.Disabled = true
script.Parent.BrickColor = BrickColor.new(26)--Black
wait(3)--Change this number to change the time in between regenerations via the button, in seconds..
script.Parent.BrickColor = BrickColor.new(104)--Purple
script.Disabled = false
end
end
local ClickDetector = Instance.new("ClickDetector", script.Parent)
ClickDetector.MouseClick:Connect(regenerate)
wait(3)--
model = backup:Clone()
model.Parent = game.Workspace
model:makeJoints()
script.Disabled = true
script.Parent.BrickColor = BrickColor.new(26)--Black
wait(3)--Change this number to change the time in between regenerations via the button, in seconds..
script.Parent.BrickColor = BrickColor.new(104)--Purple
script.Disabled = false
end
you dont need to make script disabled you can make new variable for it
local Touched = false
function regenerate()
if Touched then return end – if the variable touched still true it will return back
Touched = true – on the touched variable
model:remove()
wait(3)--
model = backup:Clone()
model.Parent = game.Workspace
model:makeJoints()
script.Parent.BrickColor = BrickColor.new(26)--Black
wait(3)--Change this number to change the time in between regenerations via the button, in seconds..
script.Parent.BrickColor = BrickColor.new(104)--Purple
Touched = false -- false/off the Touched variable