I have a script that whenever you click will check the item name and send a Remote Event to destroy the block, the event goes through and upon clicking will destroy, but instead of destroying the target it destroys my player's Workspace model.
Local Script located in StarterPlayerScripts:
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local target = nil mouse.Button1Down:Connect(function() if mouse.Target.Name == "Item" or "Item2" then target = mouse.Target game.ReplicatedStorage.BlockDestroy:FireServer(target) end end)
(Theres a Remote event in ReplicatedStorage called "BlockDestroy".)
Script in Workspace to handle the Remote Event:
game.ReplicatedStorage.BlockDestroy.OnServerEvent:Connect(function(target) target:Destroy() end)
In this line, you're using the 'or' operator incorrectly
if mouse.Target.Name == "Item" or "Item2" then
This is partitioned as "if the target's name is 'Item', or if the string 'Item2' exists, move on". You need another '==' operator, like so.
if mouse.Target.Name == "Item" or mouse.Target.Name =="Item2" then
If you want to avoid confusion, you can change the priority of the statements manually with parentheses, like so
if (mouse.Target.Name == "Item") or (mouse.Target.Name =="Item2" then)
Here's a good reference for lua operators: https://www.tutorialspoint.com/lua/lua_operators.htm