#Equiping a tool using remote events
1 messages · Page 1 of 1 (latest)
you can pass objects through remote events
how?
i tried to
nothing is working
you can do it if it exists on server and client ig
but yeah
thats waht i done
let me send
Local script in gui, so the Tool.Value is a object value that holds the tool
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local equipToolEvent = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("EquipToolEvent")
local player = game.Players.LocalPlayer
local Tool = script.Parent.Parent.CurrentEquipedTool
local button = script.Parent
button.MouseButton1Click:Connect(function()
equipToolEvent:FireServer(Tool.Value)
end)```
Handler
```lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ToolManager = require(ReplicatedStorage:WaitForChild("ToolManager"))
local remote = ReplicatedStorage.Remotes:WaitForChild("EquipToolEvent")
remote.OnServerEvent:Connect(function(player, tool)
print("Recieved")
ToolManager:EquipTool(player, tool)
end)
/
local ToolManager = {}
function ToolManager:EquipTool(player, tool)
print("Tool Manager Runned")
local character = player.Character or player.CharacterAdded:Wait()
local backpack = player:FindFirstChild("Backpack")
if not backpack then
warn("No backpack found")
return
end
for _, item in ipairs(character:GetChildren()) do
if item:IsA("Tool") and item ~= tool then
item.Parent = backpack
end
end
tool.Parent = character
print("Equipped:", tool.Name)
end
return ToolManager
equipToolEvent:FireServer(Tool.Value) you send a Value and expect a Tool instance on server?
fr tho
its a object value
print tool on server
oh right also
23:25:42.829 ReplicatedStorage.ToolManager:23: attempt to index nil with 'Parent' - Server - ToolManager:23
i got a error
good point let me check
tool.Parent = player:WaitForChild("Backpack")
so in the players backpack
only thing is
i made that with a local script
i just saw
i made the tool with a local script
thats not gonna work
yeep
thats why
server doesnt see it
yeah right that makes more sense
okay one sec
i fixed it thanks
@spiral hatch can i ask smth else rq
i get this error when i try to clear the children of my scrolling frame but idk why 23:54:38.725 Players.Teddy_arm.PlayerGui.Inventory.InventoryFrame.ScrollingFrame.InventoryController:4: attempt to index nil with 'Parent' - Studio
local scrollingFrame = script.Parent.Parent.ScrollingFrame
local InspectFrame = script.Parent.Parent.InspectFrame
scrollingFrame:ClearAllChildren()```
smth with script.Parent or script.Parent.Parent
debug it with prints