pls help me with this i dont get why it is an error
May you show the code so that I can take a look at it?
Yes I am here, sorry for the delay; try this
local region3 = Region3.new(Vector3.new(5,0,5), Vector3.new(15,15,15))
local part = Instance.new("Part")
part.Anchored = true
part.Size = region3.Size
part.CanCollide = false
part.Transparency = 0.9
part.CFrame = region3.CFrame -- You had forgot to position the part in your code earlier
part.Parent = workspace -- Parent your instance at the last
while wait() do
local PartsInRegion = workspace:FindPartsInRegion3(region3,part, 1000)
for i,v in pairs(PartsInRegion) do
if v.Parent:FindFirstChild("Humanoid") then
print("works") -- prints "Works"
end
end
end
it works know thx but how do i add it for the buttons
First
create a part and set its transparency to 1 and cancollide to false and place it above your button. Make sure to rename it to “Button1”
Second
local Button = workspace.Button1 -- Path to your button1
local region3 = Region3.new(Button.Position-(Button.Size/2),Button.Position+(Button.Size/2)) -- Formula for getting both the corners of the created part and then filling it with region
while wait() do
local PartsInRegion = workspace:FindPartsInRegion3(region3,nil, 1000)
for i,v in pairs(PartsInRegion) do
if v.Parent:FindFirstChild("Humanoid") then
local char = v.Parent
local plr = game.Players:GetPlayerFromCharacter(char) -- Getting the player
end
end
end
can i olso call it multi button becose i have rebirth buttons to and stuff
Yes you can create multiple regions for detecting multiple buttons.
must be the name of the part be the same as the button name ?
No it can be different if you know what you are doing.
my first button is called 1 multi = $125 so is it the best to name the part the same
sorry for the dumb questions sometimes
do i need to put the part in the button
You need to put the part above the button and not inside anything; you can put it inside by changing path of the variable in the above code.
can u please explain what is wrong here
can someone pls help me further
all of that is pointless really, you could achieve this, just with the Touched event, as Touched event fires whenever a certain part has been touched, it will run forever, here’s what you can do:
- (Server) Script in ServerScriptService:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local valueToBeChanged = Instance.new("IntValue")
valueToBeChanged.Name = "valueToBeChanged"
valueToBeChanged.Parent = leaderstats
end)
- (Server) Script inside the part that needs to be touched:
local debounce = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and debounce == true then
debounce = false
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local valueToBeChanged = player.leaderstats:WaitForChild("valueToBeChanged")
print("Did it!")
valueToBeChanged.Value = valueToBeChanged.Value + 1
wait(1)
debounce = true
end
end)
Ending result
Of course, it works without the second player and when CanCollide is set to either true or false on the part.
if you already have a value and the leaderstats then just change the “valueToBeChanged” to whatever the name of your value is, and delete the first script I wrote.
an example of this would be:
-
Delete the first Server Script I wrote that was planned to be in ServerScriptService
-
(Server) Script inside the part that needs to be touched:
local debounce = true --// setting up the debounce
script.Parent.Touched:Connect(function(hit) --// fires whenever it has been touched
if hit.Parent:FindFirstChild("Humanoid") and debounce == true then --// checking if what hit it has a Humanoid inside, and if debounce is true
debounce = false --// setting the debounce to false
local player = game.Players:GetPlayerFromCharacter(hit.Parent) --// finding the player
local Money = player.leaderstats:WaitForChild("Money") --// getting the value that you wanna change
print("Did it!") --// printing in the output just to make sure
Money.Value = Money.Value + 1 --// how much you want to add
wait(1) --// delay for how much it will wait until it fires the function and gives + 1 to the value again
debounce = true --// setting the debounce back to true so the code runs again
end
end)
you can change how much of the value it will give each time, how much it will wait until gives value again, and the value it will give, other than that, unless you know what you’re doing, don’t change anything else.