Chikironi
(chikironi)
October 3, 2024, 5:14am
1
I want to only allow players that have a specific item to be able to do something, but I don’t know how to check for that item.
I’ve attempted some code, but it just doesn’t do anything. If you click, nothing happens, if you click with the item that’s supposed to work, nothing happens.
Here’s the code:
Thanks for your help!
The variable Find stays constant since its defined before the function, if you put line 5 in the function then it might work
Chikironi
(chikironi)
October 3, 2024, 5:37am
3
Like this?
I tried it like this and it still didn’t work, sorry if you meant another way.
Does the function run like does it print no pancake in the output?
Chikironi
(chikironi)
October 3, 2024, 5:42am
5
Nothing prints at all, nothing about the script prints.
Oh then can u check if anything prints right after the backpack variable? I think it might be yielding the code
3txks
(Severine)
October 3, 2024, 5:45am
7
Does the click function work? Add a print statement inside it to make sure it’s running. Is the script inside a proper object and not part of Roblox Core? Also, the variable for ‘Backpack’ seems incorrect. You need to reference the player’s ‘Backpack’ instead of creating your own variable, otherwise it’s not going to work.
Chikironi
(chikironi)
October 3, 2024, 5:45am
8
Somethings prints at the backpack variable, it says “Script ‘Workspace.BlueberryMachine.Button.Tool Name Here!!!’, Line 4 - Studio - Tool Name Here!!!:4”
After that, nothing shows up about the script.
Chikironi
(chikironi)
October 3, 2024, 5:46am
9
Before I tried to add the finding function, it did work and give me the item.
3txks
(Severine)
October 3, 2024, 5:47am
10
nvm nvm my bad can you send me the cscrript ?
Chikironi
(chikironi)
October 3, 2024, 5:48am
11
So like local Backpack = plr.backpack
instead of what it was?
Chikironi
(chikironi)
October 3, 2024, 5:49am
12
local tool = game.ServerStorage["Blueberry Pancake"] local clone = tool:clone() local player = game.Players.LocalPlayer local Backpack = player:WaitForChild("Backpack") script.Parent.ClickDetector.MouseClick:connect (function(plr) local Find = player.Backpack:FindFirstChild("Stove Pancake") if Find then script.Parent.Parent.BlueberryPlainP.P1.Transparency = 0 script.Parent.Parent.BlueberryPlainP.P2.Transparency = 0 script.Parent.Parent.BlueberryPlainP.P3.Transparency = 0 if clone.Parent ~= plr.Backpack then wait(3) script.Parent.Parent.BlueberryPlainP.P1.Transparency = 1 script.Parent.Parent.BlueberryPlainP.P2.Transparency = 1 script.Parent.Parent.BlueberryPlainP.P3.Transparency = 1 script.Parent.Parent.BlueberryPancake.P1.Transparency = 0 script.Parent.Parent.BlueberryPancake.P2.Transparency = 0 script.Parent.Parent.BlueberryPancake.P3.Transparency = 0 script.Parent.Parent.BlueberryPancake.Butter.Transparency = 0 script.Parent.Parent.BlueberryPancake.Syrup.Transparency = 0.55 wait(2) clone.Parent = plr.Backpack script.Parent.Parent.BlueberryPancake.P1.Transparency = 1 script.Parent.Parent.BlueberryPancake.P2.Transparency = 1 script.Parent.Parent.BlueberryPancake.P3.Transparency = 1 script.Parent.Parent.BlueberryPancake.Butter.Transparency = 1 script.Parent.Parent.BlueberryPancake.Syrup.Transparency = 1 wait(5) else end else print('no pancake') end end)
3txks
(Severine)
October 3, 2024, 5:49am
13
variable of find , change to plr instead of player , and variable of backpack need to use inside function and change to plr too
Chikironi
(chikironi)
October 3, 2024, 5:50am
14
Should I change local player
to local plr
also?
After the click detector has been clicked does it print anything? If it does then which code does it end up running, the code after line 7 or the code after line 31?
3txks
(Severine)
October 3, 2024, 5:52am
17
You don’t need to use LocalPlayer
; the script doesn’t know who’s clicking. The only way for it to know is through the function’s parameter, which will identify who is clicking. I assume this is a server-side script since you’re using ServerStorage
.
Chikironi
(chikironi)
October 3, 2024, 5:53am
18
Nothing prints after clicking it.
Chikironi
(chikironi)
October 3, 2024, 5:54am
19
Should I do something instead of LocalPlayer then?
3txks
(Severine)
October 3, 2024, 5:55am
20
local tool = game.ServerStorage["Blueberry Pancake"]
local clone = tool:Clone()
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local playerBackpack = plr:WaitForChild("Backpack")
local find = playerBackpack:FindFirstChild("Stove Pancake")
if find then
script.Parent.Parent.BlueberryPlainP.P1.Transparency = 0
script.Parent.Parent.BlueberryPlainP.P2.Transparency = 0
script.Parent.Parent.BlueberryPlainP.P3.Transparency = 0
if clone.Parent ~= playerBackpack then
wait(3)
script.Parent.Parent.BlueberryPlainP.P1.Transparency = 1
script.Parent.Parent.BlueberryPlainP.P2.Transparency = 1
script.Parent.Parent.BlueberryPlainP.P3.Transparency = 1
script.Parent.Parent.BlueberryPancake.P1.Transparency = 0
script.Parent.Parent.BlueberryPancake.P2.Transparency = 0
script.Parent.Parent.BlueberryPancake.P3.Transparency = 0
script.Parent.Parent.BlueberryPancake.Butter.Transparency = 0
script.Parent.Parent.BlueberryPancake.Syrup.Transparency = 0.55
wait(2)
clone.Parent = playerBackpack
script.Parent.Parent.BlueberryPancake.P1.Transparency = 1
script.Parent.Parent.BlueberryPancake.P2.Transparency = 1
script.Parent.Parent.BlueberryPancake.P3.Transparency = 1
script.Parent.Parent.BlueberryPancake.Butter.Transparency = 1
script.Parent.Parent.BlueberryPancake.Syrup.Transparency = 1
wait(5)
end
else
print("Error")
end
end)
1 Like