What do you want to achieve? Fix my simple script.
What is the issue? My script is not working.
What solutions have you tried so far? I tried to look at DevForum but i din’t found an solution.
My script:
local event = game.ReplicatedStorage:WaitForChild("ToolBackpackEvent")
event.OnServerEvent:Connect(function(player)
local char = player.Character
local tool = player.Backpack.Gun
print("tool parent is " .. tool.Parent)
end)
Its saying that the gun is not a parent of the player’s backpack, why this is happening?
May I ask, what is the purpose of this function, clearly the tool, which is player.Backpack.Gun has a parent of player.Backpack, so why are you checking this?
local event = game.ReplicatedStorage:WaitForChild("ToolBackpackEvent")
event.OnServerEvent:Connect(function(player)
local char = player.Character
local tool = player.Backpack:WaitForChild("Gun")
print("tool parent is " .. tool.Parent)
end)
local player = game.Players.LocalPlayer
local rs = game.ReplicatedStorage
local Event = rs.CharEvent
local backpack = rs.CharBackpack
script.Parent.Changed:Connect(function()
if script.Parent.Value == 4 then
Event:FireServer()
else
backpack:FireServer()
end
end)
That script isn’t firing the same event that the server script is having problems with. They’re named differently. What LocalScript fires the ToolBackpackEvent RemoteEvent?