Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make a working Destroy baseplate script?

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

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 :)

1 comment

0

thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.