I have a remote event from a client to a server. It is under an image button under ScreenGUI. For some reason it is not printing "hello!!!" when I press the button. Why is this not happening? I don't see anything wrong with the code. Is there a problem of where the code is placed or something?
- client code
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)
- server code
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local destroyToolEvent = Instance.new("RemoteEvent", ReplicatedStorage)
destroyToolEvent.Name = "DestroyToolEvent"
print("heyyyy")
local function onCreatePartFired(player, tool)
local SG = player.StarterGear
print("hello!!!")
tool:Destroy()
if SG:FindFirstChild(tool.Name) then
SG[tool.Name]:Destroy()
end
end
destroyToolEvent.OnServerEvent:Connect(onCreatePartFired)
