Event.OnServerEvent:Connect(function(player, item, animation, frame)
--print(player, item, animation, frame.Name)
local Tool = item:Clone() -- Clones the item
Tool.Parent = game.Workspace.player -- Gives it to player
Tool.Name = "EquippedWeapon"
local char = game.Workspace.player
char.Animate.toolnone.ToolNoneAnimation.Id = "http://www.roblox.com/asset/?id="..animation
frame.Parent = frame.Parent.Parent
frame:TweenPosition(UDim2.new(-1.015, 0, 0.771, 0),"Out","Quart",0.1) -- Side of the screen
end)
This is what I currently have set up for giving an item to a player but for some reason it doesn’t want to parent and I get an error saying that player is not a valid member of workspace. Not sure how to do this, I did add a characteradded event and that didn’t seem to work, so I am not sure what to do. Player is the name of the player which gets sent from the client to the server.
Event.OnServerEvent:Connect(function(player, item, animation, frame)
local char = player.Character or player.CharacterAdded:Wait()
local tool = item:Clone()
tool.Name = "EquippedWeapon"
tool.Parent = char
-- rest of your code. Use "char" to reference the character, and "player" to reference the player
end
script.Parent.MouseButton1Click:Connect(function()
local item2 = script.Parent.Parent.ItemView:GetChildren()
for i, v in pairs(item2) do
if v:IsA("Tool") then
for _, c in pairs(v:GetChildren()) do
if c:IsA("Script") then
local tool = v
local animation = c:WaitForChild("Animation"):WaitForChild("Id").Value
local frame = script.Parent.Parent
local char = player.Character
Equip_Event:FireServer(char, tool, animation, frame)
end
end
end
end
end)