ROBLOX Studio is a server simulated on a client, it's confusing, but don't worry. We can use the client to detect when the brick has been touched, you haven't provided context, though. I'm doing it in the case as if you're waiting for a player to step on it (This will still work if you're trying to use some sort of raining parts, but this script would be less efficient for that, I suggest putting a debounce on the server instead).
Server script, this could either go in Workspace or ServerScriptService.
local network = Instance.new("RemoteEvent", game.ReplicatedStorage)
network.OnServerEvent:connect(function(player, part)
part.Anchored = true
end)
Client script, this could either go in LocalPlayer, PlayerGui, StarterPack or StarterPlayerScripts.
local network = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local debounce = false
workspace.Part.Touched:connect(function(hit)
if debounce == false then
debounce = true
network:FireServer(workspace.Part)
wait(0.5)
debounce = false
end
end)
As I said I'm doing it in the sense that you want a player to touch the brick, not what I think you're trying to do (Raining parts that anchor on floor hit).
5 comments
Maybe use a direct function? Like script.Parent.Touched:connect(function(hit) end)
Thanks for suggesting this, but it still functions slow.
use client
xuefei123: of course that makes no difference at all. they mean exactly the same thing.
make it work with the client