Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make a working Destroy baseplate script?

Asked by 5 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(key)

if key.KeyCode == Enum.KeyCode.F then

game.Workspace.Baseplate:Destroy()

end

end)

1 answer

Log in to vote
0
Answered by
Dalamix 26
5 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

Well, roblox has a thing called Filtering Enabled. So basically to make this work, you need a RemoteEvent. First off, add a RemoteEvent to ReplicatedStorage. Name it "DestroyEvent" with capitals too. Then in your local script write this:

-- Variable for the remoteEvent local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("DestroyEvent")

-- Variable for the UserInputService local UIS = game:GetService(“UserInputService”)

-- When the player presses a button all the stuff below happens. UIS.InputBegan:Connect(function(key)

--If the input is equal to "F" if key.KeyCode == Enum.KeyCode.F then

--Fire the remote event so the server can destroy the baseplate. remoteEvent:FireServer()

end

end)

After that, put a normal script into ServerScriptService. Name it so you know what its about, and then write this inside of it:

--Variable for the remoteEvent. local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("DestroyEvent")

--When a client fires the remote event, this function will come into play. remoteEvent.OnServerEvent:Connect(function() workspace.Baseplate:Destroy() end)

Thats it! Just added some notes if you need them :)

0
thanks flamingrobot1 -5 — 5y
Ad

Answer this question