I really need help with this as I need it done today, because it is a commission. When I try to fire a remote event located in the ReplicatedStorage, it does not fire, because I have a script that detects whether or not it has fired in the ServerScriptService and it has a print statement in it, but nothing is printing. Here is the code for the client LocalScript in the tool:
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:Connect(function()
script.Parent.Fire:FireServer(mouse.Hit.p)
end)
game:GetService("UserInputService").InputBegan:Connect(function(k, typing)
if k.KeyCode == Enum.KeyCode.P and script.Parent.Equipped and not typing then
-- That damn problem happens here
script.Parent.putBackTool:FireServer("putBackTool", script.Parent.Name, script.Parent)
end
end)
If you need me to give you the server script code, I will. I’m doing this for a commission and I’ve been trying to fix this for multiple days already and the person, from the looks of it, is not looking so happy.
The basic description of the hierarchy is there is a tool that gets cloned from the ReplicatedStorage to your inventory once you do something, and also when you press P it should fire a remote event that sets a value to true and you should have the tool back in your inventory
it was literally in the other post thing but oh well
local dss = game:GetService("DataStoreService")
local ds = dss:GetDataStore("InventoryData")
function saveData(p)
local inventory = {}
for i, value in pairs(p.Inventory:GetChildren()) do
inventory[value.Name] = value.Value
end
ds:SetAsync(p.UserId, inventory)
end
game.Players.PlayerAdded:Connect(function(p)
local invFolder = Instance.new("Folder", p)
invFolder.Name = "Inventory"
for i, item in pairs(game.ReplicatedStorage.Items:GetChildren()) do
local newValue = Instance.new("IntValue")
newValue.Name = item.Name
newValue.Value = 0
newValue.Parent = invFolder
end
p.CharacterAdded:Connect(function(c)
c.Humanoid.Touched:Connect(function(hit)
if hit:FindFirstChild("ITEM") then
invFolder[hit.Name].Value += 1
hit:Destroy()
elseif hit.Parent:IsA("Tool") and hit:FindFirstChild("ITEM") then
invFolder[hit.Name].Value += 1
hit:Destroy()
end
end)
end)
saveData(p)
local invData = ds:GetAsync(p.UserId) or {}
for itemName, itemCount in pairs(invData) do
invFolder[itemName].Value = itemCount
end
end)
game.ReplicatedStorage.InventoryRE.OnServerEvent:Connect(function(p, instruction, item, path)
if instruction == "drop" and p.Inventory:FindFirstChild(item) and p.Inventory[item].Value == 1 then
p.Inventory[item].Value -= 1
local newItem = game.ReplicatedStorage.Items[item]:Clone()
newItem.CFrame = p.Character.HumanoidRootPart.CFrame - p.Character.HumanoidRootPart.CFrame.LookVector * 5
newItem.Parent = workspace
elseif instruction == "equip" and p.Inventory:FindFirstChild(item) and p.Inventory[item].Value == 1 then
p.Inventory[item].Value -= 1
local newItem = game.ReplicatedStorage.Items[item]:Clone()
newItem.Parent = p.Backpack
elseif instruction == "dropTool" and p.Inventory:FindFirstChild(item) and p.Inventory[item].Value == 1 then
p.Inventory[item].Value -= 1
local newItem = game.ReplicatedStorage.Items[item]:Clone()
local newItem2 = newItem.Handle
newItem2.Parent = workspace
for i,v in pairs(newItem2:GetChildren()) do
v:Destroy()
end
script.ITEM:Clone().Parent = newItem2
newItem:Destroy()
newItem2.CFrame = p.Character.HumanoidRootPart.CFrame - p.Character.HumanoidRootPart.CFrame.LookVector * 5
newItem2.Name = game.ReplicatedStorage.Items[item].Name
elseif instruction == "putBackTool" and p.Inventory:FindFirstChild(item) and p.Inventory[item].Value == 0 and path then
print("fired")
local newItem = game.ReplicatedStorage.Items[item].Handle:Clone()
for i, v in pairs(newItem:GetChildren()) do
if v.Name == "ITEM" then
continue
else
v:Destroy()
end
end
newItem.Name = item
newItem.CFrame = p.Character.HumanoidRootPart.CFrame - p.Character.HumanoidRootPart.CFrame.LookVector * 5
newItem.Parent = workspace
end
end)
game.Players.PlayerRemoving:Connect(saveData)
game:BindToClose(function()
for i, p in pairs(game.Players:GetPlayers()) do
saveData(p)
end
end)