I have a localscript that fires a remoteevent when a textbutton is clicked, the event welds a meshpart to the right hand from the server script. the problem is that i dont have a variable for the player. i accepted the callback from the remote event and it gives me this error.
15:41:41.583 - Players.Ruunic.PlayerGui.Inventory.Rock.Script:24: attempt to call field 'OnServerEvent' (a userdata value)
keep in mind that i need the player value as a global variable, as i use it in a mouse.Button1Down function later.
-- Server
ev2.OnServerEvent(p):connect(function()
local hc = item:FindFirstChildWhichIsA('MeshPart')
local c = p.Character
mouse = p:GetMouse()
if not equipped then
equipped = true
item.Parent = workspace
weld(hc,c.RightHand)
elseif equipped then
equipped = false
hc.WeldConstraint:Destroy()
item.Parent = p.PlayerGui.Inventory
c.RightHand.WeldConstraint:Destroy()
end
end)
--Client
local p = game.Players.LocalPlayer
local item = p.PlayerGui.Inventory.Rock
script.Parent.Text = item.Name
local c = p.Character
local mouse = p:GetMouse()
--local hAnim = game.ReplicatedStorage.Animations.Slash
local equipped = false
local iName = item.Name
local ev = game.ReplicatedStorage.Events.Equip
local drop = game.ReplicatedStorage.Events.Drop
--game.ReplicatedStorage.Events.GetPlayer:FireServer(p)
function drop()
drop:FireServer()
--[[item:FindFirstChildOfClass('MeshPart').Position = c.UpperTorso.Position + Vector3.new(0,4,0)
item.Parent = workspace]]
end
script.Parent.MouseButton1Click:connect(function()
ev:FireServer(p)
end)
if item.droppable.Value == true then
script.Parent.MouseButton2Click:connect(drop)
else
script.Parent.Parent.Parent.drop.Visible = true
wait(1.5)
script.Parent.Parent.Parent.drop.Visible = false
end
my code is sloppy, i know. i just gotta get this one thing done to finish my game lol
