I am trying to use a remote event from a client to a server. Below are my two scripts which are both below an image button:

  1. client
local Players = game:GetService("Players")
plr = game:GetService("Players").LocalPlayer

char = plr.Character or plr.CharacterAdded:Wait()


print("hekki")
script.Parent.MouseButton1Click:Connect(function()
	print("hello!")
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local destroyToolEvent = ReplicatedStorage:WaitForChild("DestroyToolEvent")
 	
	local tool = char:FindFirstChildOfClass("Tool")
	destroyToolEvent:FireServer(tool)
	
	
end)

  1. server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local destroyToolEvent = Instance.new("RemoteEvent", ReplicatedStorage)
destroyToolEvent.Name = "DestroyToolEvent"
 
local function onCreatePartFired(player, tool)
	local SG = player.StarterGear
	if tool then

		print("hello!!!")
		tool:Destroy()
		
	end
	if SG:FindFirstChild(tool.Name) then
    	SG[tool.Name]:Destroy()
	end
end
 
destroyToolEvent.OnServerEvent:Connect(onCreatePartFired)

When I run "hekki" is printed and "hello!" is printed every time i press the button. However, "hello!!!" is never printed. What's the issue?

2 comments