I am making a test game, and I thought you could access backpack items just by calling,
``
player.Backpack.ITEM
But I guess you can't, because I am getting the error, ``
10:53:33.764 - Wand is not a valid member of Backpack
Here is my server script that is being called from a localscript when the wand is activated,
``
local repStorage = game:GetService("ReplicatedStorage")
local castSpellEvent = repStorage:WaitForChild("CastSpell")
castSpellEvent.OnServerEvent:connect(function(player, word)
print(word)
if word == "ReFe" then
local yeet = player:WaitForChild("Backpack")
print("ReFe FIREWHIP")
local ray = Ray.new(yeet.Wand.Handle.CFrame.p,
yeet.Wand.Handle.CFrame.p.unit * 300)
local part, position = workspace:FindPartOnRay(ray, player.Character, true, true)
local beam = Instance.new("Part", workspace)
beam.Name = "FireWhip"
local distance = (player.Character.HumanoidRootPart.Position - position).magnitude
beam.BrickColor = BrickColor.new("Bright red")
beam.Locked = true
beam.Anchored = true
beam.Size = Vector3.new(0.3, 0.3, distance)
beam.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position,
position) * CFrame.new(0, 0, -distance / 2)
if part then
local humanoid = part.Parent:FindFirstChild("Humanoid")
if not humanoid then
humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
end
if humanoid then
humanoid:TakeDamage(30)
end
end
end
end)

1 comment
Sorry for the terrible formatting, I don't really understand how to use the code blocks on here.