Hello, I have a script for auto train, that is, an autoclicker, and I would like to change it so that when a local player takes a force in his hands, that is, a tool, only this tool does work for him But I would like it if when a local player takes other tools from him they don’t work
local MarketPlaceService = game:GetService("MarketplaceService")
local gamepassId = 251630884
local OwnsGamepass = false
local function ownsgamepass(userId, gamepassId)
local s,res = pcall(MarketPlaceService.UserOwnsGamePassAsync, MarketPlaceService, userId,
gamepassId)
if not s then
res = false
end
OwnsGamepass = res -- You never actually called ownsgamepass. I made it serve a purpose within this script.
return res
end
local cps = 360 -- Can be a maximum of 60
local active = false
script.Parent.MouseButton1Click:Connect(function()
active = not active
script.Parent.Round.ImageColor3 = Color3.fromRGB(234,0,0)
script.Parent.Text = "Off"
end)
local player = game:GetService("Players").LocalPlayer
ownsgamepass(player.UserId, gamepassId)
while true do
if active and player.Character and OwnsGamepass then -- The player will always exist in a local script.
script.Parent.Round.ImageColor3 = Color3.fromRGB(0,255,0)
script.Parent.Text = "On"
local tool = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Tool")
if tool then
tool:Activate()
end
end
-- The script.Parent.MouseButton1Click thing would cause the number of times it fire to increase dramatically over time, so I removed it
task.wait(30/cps) -- task.wait allows for 1/60 intervals rather than 1/30 intervals
end
That is, I want 1 item, the tool, to work and not others.
At the moment, I take any tools in my hands, they will work, but I want 1 tool to work, but I don’t know how to do it, help me do it
You can check if the tool has a specific name.
if tool then
if tool.Name == "ToolName" then
tool:Activate()
end
end
I have a question, is it possible to make it so that when you pick up a tool, it works and you can’t turn it off through the settings?
I have it set up so that you can turn off this type of autoclicker, I want to make it so that it can’t be turned off
Are you saying for the autoclicker to always be on?
Yes, I want to do exactly that.
And can you help me later where to write this script and what kind of script, local or server
An autoclick script should definetly be client-sided.
Also, to make the autoclicker always stay on, remove these parts of the script:
script.Parent.MouseButton1Click:Connect(function()
active = not active
script.Parent.Round.ImageColor3 = Color3.fromRGB(234,0,0)
script.Parent.Text = "Off"
end)
script.Parent.Round.ImageColor3 = Color3.fromRGB(0,255,0)
script.Parent.Text = "On"
And remember to set active
to true
at all times.
This is not what I wanted, I wanted it so that when a player bought a game pass, the auto train would automatically start working for him.
Oh, so its automatically turned on once they bought it?
In this case, I would just set active
to true at the start of the script.
Sorry, if you didn’t understand me, I have a game pass shop and when a local player went to buy a pass, he saw a car train and bought it and after the purchase, his power level started to increase, that is, the tool
Let me send you the pass script of this product and do everything you need in it
After the purchase, auto-pumping began when the player takes the instrument of power into his hands
I’m sorry, your wording is really confusing for me to understand.
Look, I go into the game and see the auto train pass and I buy it and after buying I don’t need anything else, I click on the tool and the auto train starts
That is, the script starts working by itself and there is no need to write off on there, the script just starts working automatically