Hi, so I’m going to try and be as clear as possible when explaining this because I had trouble trying to word it at all
So what I’m trying to do here is make a tool, a die tool, that when rolled gives you a random item from a folder in ReplicatedStorage. Right now I’m just trying to get the basic thing done and then work on cooldowns and stuff
The main issue is that, well, it isn’t working at all. It does not give me any errors either and printing doesn’t seem to be working for debugging either.
This is what it looks like in the explorer
(Excuse the use of free tools/models, it’s temporary for testing)
and this is what the script for the D6 itself looks like
local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Folder = RS:WaitForChild("D6Items")
script.Parent.Activated:Connect(function()
local Tools = Folder:GetChildren()
local ToolsTable = Tools
local chosenTools = {}
repeat
local selectedIndex = math.random(1, #ToolsTable)
table.insert(chosenTools, ToolsTable[selectedIndex])
table.remove(ToolsTable, selectedIndex)
until #chosenTools >= 1
local plr = Players:GetPlayerFromCharacter()
for i,v in pairs(chosenTools) do
Folder:FindFirstChild(v.Name):Clone().Parent = plr.Backpack
end
end)
I modified my code to go with yours and added print statements, still, nothing happened. Nothing prints at all when the tool activates and I’m not getting any errors
Modified code
local SS = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local Folder = SS:WaitForChild("D6Items")
script.Parent.Activated:Connect(function()
local Tools = Folder:GetChildren()
local ToolsTable = Tools
local chosenTools = {}
print("Works up until here")
repeat
local selectedIndex = math.random(1, #ToolsTable)
table.insert(chosenTools, ToolsTable[selectedIndex])
table.remove(chosenTools,table.find(chosenTools[selectedIndex]))
until #chosenTools >= 1
print("Will it work...")
local plr = Players:GetPlayerFromCharacter()
for i,v in pairs(chosenTools) do
Folder:FindFirstChild(v.Name):Clone().Parent = plr.Backpack
end
end)
local SS = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local Folder = SS:WaitForChild("D6Items")
script.Parent.Activated:Connect(function()
local Tools = Folder:GetChildren()
local ToolsTable = Tools
local chosenTools = {}
print("Works up until here")
local selectedIndex = math.random(1, #ToolsTable):Clone()
selectedIndex.Parent = game.Workspace
print("Will it work...")
local plr = Players:GetPlayerFromCharacter()
for i,v in pairs(chosenTools) do
Folder:FindFirstChild(v.Name):Clone().Parent = plr.Backpack
end
end)
In that image you’re detecting logs from the client, the server is running this code, so click on the Server button right next to Client in your output
I imagine everything is working fine, you’re actually just setting the parent of your tools to nil since you didn’t provide your character to the GetPlayerFromCharacter method
EDIT: You also call Clone on the return result of math.random, make sure you get your instance beforehand