#Why is this not working
98 messages · Page 1 of 1 (latest)
Do you see "No!" printed in the console?
I would add more prints to see how far the code is getting to track down where it is failing.
Such as a print after line 62 to make sure you are even calling the function.
Then a print after line 75 to test your member check is working
No i don't
None of these are being printed
Do you see "Clicked" ?
** You are now Level 5! **
Yup
Cool, so the problem lies with receiving the server event. When/how does enable.OnServerEvent:Connect(enableButton) get called?
when i click the button to enable the autoclicker
but the :Connect function is what binds the button event to the client. So how is that going to get called if you haven't binded the event on the client before?
i did bind it
her
Oh sorry I was reading backwards. You are sending an event to the server enable.
Then on the server you want to receive it and call the function enableButton. However, the line that tells the server to call the function enableButton is inside the function enableButton. So it doesn't get bound until enableButton is called at least once.
but on my other script its also inside and it works fine
** You are now Level 6! **
so i should change the local function to a function?
nvm
let me try if it works after i put it outside
progress!
in my other function, how does the script know what "player" means if i havent defined it anywhere
Hi
player must be defined somewhere on a line above onEnd for that one to work
sorry, in a meeting can't reply fast
its a whole different function
I'm gonna off
but if anyone wanna help me you can write and i will check later
Ah so in the case of onEnd Roblox API PlayerAdded is giving you that reference to the player instance (see parameters). That is how onEnd has access to it. https://create.roblox.com/docs/reference/engine/classes/Players#PlayerAdded
player is only available inside of the function(player) .. end) block of code, it is only available within that scope. See: https://create.roblox.com/docs/luau/scope
You could move your enableButton function inside of that scope. But also notice that OnServerEvent can give you player(the player that sent the event) in the same way that PlayerAdded gives you player: https://create.roblox.com/docs/reference/engine/classes/RemoteEvent#OnServerEvent
This error?
plyr based on what I can see appears to be a reference to the Players service (https://create.roblox.com/docs/reference/engine/classes/Players). Not a specific player.
what should i do
change line 62 to local function enableButton(player) to grab the specific player that sent the event out of the OnServerEvent. Then use the player variable inside of your function
does the scope reach that far
enableButton function has its own scope and we are passing player into it. It is not the same player that onEnd has.
so i dont need to define player except for passing it in the function
Correct, you can say that OnServerEvent has defined it for you and you are passing it through to your enableButton function
haha you didn't seem slow at all, all good questions
lol i'm studying for 4 tests and making game at the same time with 3 screens
ty bro
Haii
Yo, where did you get the code Enum.GroupRole.Member? That doesn't appear to be part of Roblox
Check out the docs on GetRoleInGroup: https://create.roblox.com/docs/reference/engine/classes/Player#GetRoleInGroup
It returns you a string back.
What I would do is print groupMembership and play as a member and see what it is set to. Then change the if condition to groupMembership ~= "{whatever_it_printed}"
but i only want to check if they're in the group not role
Okay, the docs say:
The GetRoleInGroup Player function returns the player's role in the group as a string, or Guest if the player isn't part of the group.
So it looks like you can check groupMembership == "Guest" -> they are not in the group
I still think it would be valuable to print(groupMembership) and play as a player in the group/not in group to confirm what value you need to use
Replace line 71 with if groupMembership ~= "Guest" then
That error is telling you Enum.GroupRole.__ doesn't exist, you can't have Enum.GroupRole in your code
It works
But it isn't stopping when i click it again
how do i make it stop when clicked again
One approach is to set autoClickerEnabled to false when you click again. But remember the idea of scope. You are declaring a new autoClickerEnabled variable every time you click the button, so each click of the button can't see or change the variable from the last time.
So think about how you can have a shared autoClickerEnabled variable and check it each time you call the function. If it is true then set it false, if it is false then set it true and start looping
ANother idea is have the client send the desired true/false in the remoteEvent:
client wants to disable autoclicker:
enable:FireServer(false)
client wants to enable autoclicker:
enable:FireServer(true)
maybe local autoclickerdisabled
how
wdym false true
this?
but i maybe need another remoteevent for when i disable
Close, I mean have the localscript remember if autoclicker is on or off, so each time you click you tell the server you want it to become opposite.
local isAutoClickerEnabled = false
button.MouseButton1Click:Connect(function()
isAutoClickerEnabled = not isAutoClickerEnabled -- if true it becomes false, if false it becomes true
enable:FireServer(isAutoClickerEnabled)
print("sent autoClickerEnabled", isAutoClickerEnabled)
end)
You might find this video useful https://youtu.be/lbGvLQ2uGzs?si=UrUHpAAWozix5nQo&t=570
this makes me get +1 click everytime i click the autoclicker button
bro
my upgrade aint working with autoclicker
i had to write it twice in order for it to work with both manual and auto clicking
Btw you can paste code in discord with three ticks ```
You've got a lot of moving parts in your script I won't be able to get your entire feature working. I can only offer direction.
You want the autoclicker to run, and then when the user earns an upgrade they should start earning more money from the autoclicker?
The fundamental problem with your approach is you have a while loop created inside the enableButton function. After you call it once and it starts looping it becomes difficult to ever change anything about what the loop is doing.
That video I sent has an approach where the autoclicking while loop lives in the script scope so it can use all the shared variables from the entire script.
i made a upgrade system where if you reach 100 value you go to another level manually but it aint working with the autoclicker
only if i click manually
my whole script broke
now it aint changing size
now im not gaining anything
@outer flare
):
local part = workspace._PARTS.Part
local originalsize = part.Size
local newsize = Vector3.new(10, 10, 10)
local click = game.ReplicatedStorage.Click
local holdend = game.ReplicatedStorage.HoldEnd
local enable = game.ReplicatedStorage.Enable
local sound = workspace.Click
local plyr = game:GetService("Players")
plyr.PlayerAdded:Connect(function(player)
local function onRemote()
part.Size = newsize
local particle = part.Glitch
particle.Enabled = true
end
local levelUpBlocks = 100
local function onEnd()
part.Size = originalsize
local leaderstats = player:FindFirstChild("leaderstats")
local luckyBlocks = leaderstats:FindFirstChild("🌈Lucky Blocks")
local Diamonds = leaderstats:FindFirstChild("Diamonds")
local currentLevelValue = leaderstats:FindFirstChild("Level")
if leaderstats and leaderstats:FindFirstChild("🌈Lucky Blocks") then
luckyBlocks.Value = luckyBlocks.Value + (1 * currentLevelValue.Value)
if luckyBlocks.Value >= levelUpBlocks and currentLevelValue then
luckyBlocks.Value = 0
levelUpBlocks = levelUpBlocks * 2
currentLevelValue.Value = currentLevelValue.Value + 1
Diamonds.Value += math.random(1, 1000)
if currentLevelValue then
local newluckyBlocks = luckyBlocks.Value * levelUpBlocks
luckyBlocks.Value = luckyBlocks.Value + newluckyBlocks
end
print("Current Level:", currentLevelValue.Value)
print("Lucky Blocks:", luckyBlocks, "Level Up Blocks:", levelUpBlocks)
else
return luckyBlocks
end
end
end
click.OnServerEvent:Connect(onRemote)
holdend.OnServerEvent:Connect(onEnd)
end)```
local function enableButton(player)
print("Cal")
local GROUP_ID = 16730316
local groupMembership = player:GetRoleInGroup(GROUP_ID)
local leaderstats = player:FindFirstChild("leaderstats")
local luckyBlocks = leaderstats:FindFirstChild(":rainbow:Lucky Blocks")
local currentLevelValue = leaderstats:FindFirstChild("Level")
local button1 = game.StarterGui.Coins.Frtame.FreeAuto
local autoclickerEnabled = false
local autoclickerDisabled = true
if groupMembership ~= "Member" then
print(groupMembership)
local autoclickerEnabled = true
local autoclickerDisabled = false
button1.ImageColor3 = Color3.new(0, 1, 0)
while autoclickerEnabled do
luckyBlocks.Value = luckyBlocks.Value + (1 * currentLevelValue.Value)
wait(0.1)
end
elseif groupMembership == nil then
button1.ImageColor3 = Color3.new(1, 0, 0)
print("No!")
end
end
enable.OnServerEvent:Connect(enableButton)```
Haii everyone
ok
** You are now Level 7! **
@rocky egret
Hey, you've got a lot of code and it's not entirely clear to me what your desired outcome is. What order you are triggering things etc.
I would suggest adding prints throughout the code that isn't working to nail down which exact line is not working as expected.
u know what i want
i made a upgrade system where if you reach 100 value you go to another level manually but it aint working with the autoclicker
only if i click manually
my whole script broke
now it aint changing size
now im not gaining anything
sounds like you have a ton of different systems all trying to change + read luckyBlocks value? But also sounds like onEnd() didn't trigger because you mentioned size didn't change?
Idk there is just too much going on for me to understand over discord, you'll have to dial in to a single problem and find a specific error, then I might be able to help
but it should be that once i reach 100 value it goes to a level automaticallyu
but thats in the function where i click tho
so if i dont click it wont work
😠
My game is never gonna get done