Hey developers!
I’m confused on this line here which it keeps doing a error.
But i’m gonna put a function too because it requires a function to work properly
game.ReplicatedStorage.RemoteEvents.DropBackpackItem.OnServerEvent:Connect(function(user,dropeverything,item)
if dropeverything == true then
for i,v in pairs(game.ReplicatedStorage.PlayerBackpacks[user.Name]:GetChildren()) do
v.Parent = workspace
v.CFrame = user.Character.HumanoidRootPart.CFrame
end
else
local CItem = game.ReplicatedStorage.PlayerBackpacks[user.Name][item]
CItem.Parent = workspace
CItem.CFrame = user.Character.HumanoidRootPart.CFrame
end
end)
The line that causes the error is
local CItem = game.ReplicatedStorage.PlayerBackpacks[user.Name][item]
edit:
i’ve tried so much stuff that i didn’t find the solution for it.
edit 2: forgot to tell that it works with this line here:
game.Players.PlayerAdded:Connect(function(plr)
local NewFolder = Instance.new("Folder")
NewFolder.Parent = game.ReplicatedStorage.PlayerBackpacks
NewFolder.Name = plr.Name
end)
Is the parameter Item a string or instance.
Its an instance. I will make some type of backpack
But i’m making when it dies it drops everything. I guess the if statement checks the else for if its not true…
If dropeverything is false or nil it will run the else statement.
Yeah but the problem rn is the line showing on this post
Do you have any solution to it?
try
game.ReplicatedStorage.PlayerBackpacks[user.Name][item.Name]
What is the error you are getting.
ServerScriptService.Script:18: invalid argument #2 (string expected, got boolean)
that didnt work, causing this:
ServerScriptService.Script:18: attempt to index boolean with ‘Name’
Try printing the item parameter. Tell me what you get.
What does user parameter print and the item parameter print.
the user parameter prints the username
the item parameter doesn’t print anything doing a error
What arguments do you send to the server from the local script.
What your local script code.
game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function()
game.ReplicatedStorage.RemoteEvents.DropBackpackItem:FireServer(game.Players.LocalPlayer,true)
end)
also contains the Humanoid.Died thing
you dont have to have game.Players.LocalPlayer as a argument roblox sends it on its own.
try
game.ReplicatedStorage.RemoteEvents.DropBackpackItem:FireServer(true)
2 Likes
It works! Thank you so much! Now i can continue on in my project!
1 Like