so i took a tool that can delete any part it clicks if the part is unlocked, and it works perfectly fine except it only deletes the part locally, not for all players. idk how to make it delete for all players, how to do it
here is the model of it:
so i took a tool that can delete any part it clicks if the part is unlocked, and it works perfectly fine except it only deletes the part locally, not for all players. idk how to make it delete for all players, how to do it
here is the model of it:
Use remote events and send the part to the server and delete it on the server. Don’t ask me to give you a script though.
ye about that, i need a script
can u give a script. becuz i suck at scripting
We aren’t allowed to hand out scripts. That way you won’t learn anything at all. Here, is a more detailed explaination though:
You need to use Remote events to send the data to the server, how?
Remote Events have a method called RemoteEvent:FireServer(parameters)
where you can replace the parameters with your data, in this case, Mouse.Target
. So now, how to recieve this data? Use a event of the RemoteEvent that is: RemoteEvent.OnServerEvent
then connect it to a function like: RemoteEvent.OnServerEvent:Connect(function(player,parameters) end)
Do remember that the first parameter will ALWAYS be the player who sent the message so now you can use this information to destroy the part on the server.
all i know about lua coding is like game,Workspace.Part.Transparency and stuff like that or script.Parent:Destroy()
while it is obviously stated to not ask people for scripts:
Please do not ask people to write entire scripts or design entire systems for you.
here’s how you can do it.
Create 3 instances inside your tool: Script, Local Script, Remote Event.
if your tool doesn’t have a handle, then uncheck this from properties.
put this inside the local script (with explanation):
local Player = game:GetService("Players").LocalPlayer -- Gets the local player
local Mouse = Player:GetMouse() -- gets the local player's mouse
local Tool = script.Parent -- gets the tool
local RemoteEvent = Tool.RemoteEvent -- gets the Remote Event inside the tool
Tool.Activated:Connect(function() -- Fires on left button click
if Mouse.Target:IsA("Part") then -- checks if the mouse target (Part clicked on) is a part
RemoteEvent:FireServer(Mouse.Target) -- fires the remote event with the mouse target as the parameter
end
end)
local Tool = script.Parent -- gets tool
local RemoteEvent = Tool.RemoteEvent -- gets remote event inside tool
RemoteEvent.OnServerEvent:Connect(function(player, HitPart) -- remote event recieved with the mouse target param
HitPart:Destroy() -- destroys the mouse target aka part you clicked on
end)
Note: its better to have the server script inside “ServerScriptStorage”, and the remote event inside “ReplicatedStorage”.
I told you literally everything. Use the documentation to learn more stuff.
can u change the scripts to make it so u cant delete locked parts ( also sorry for asking for whole scripts, ill “try” to make myself next time )
sure, replace the local script i sent you with this:
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local Tool = script.Parent
local RemoteEvent = Tool.RemoteEvent
Tool.Activated:Connect(function()
local MouseTarget = Mouse.Target
if MouseTarget ~= nil and MouseTarget:IsA("Part") and not MouseTarget.Locked then
RemoteEvent:FireServer(Mouse.Target)
end
end)
tysm it works, il try adding my handle myself
you can select this as answer and close the topic btw
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.