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

How would I make my old stamper script FilteringEnabled-friendly?

Asked by 4 years ago

Hey all, I recently dug up a stamper tool I made a few years back and touched it up a little bit. It inserts an object wherever you want by cloning it from ReplicatedStorage and inserting it into the workspace. That all works fine, but the problem starts when playing with friends... we're unable to see each other's creations, they're all client-sided (I guess) so we can only see what we built ourselves.

I've done a bit of reading on RemoteEvents and RemoteFunctions (though I'm not sure which of the two to use), and I'm a little rusty, having not coded in over a year. Before I continue to attempt to learn that, however, are there any other ways I'd be able to fix the problem about? Just looking to explore my options :)

0
My guess would be to use RemoteEvents because those could run to a serverhandler which could then mess with the stamping blocks and placement. But say a type of block is selected, you could do a remove event when a block is "placed" and then shoot the event to the server which then actually places the block B0NBunny 11 — 4y
0
Thank you to everyone who answered!! It means a lot. I'll do some work with this information in mind and I'll get back to you all when I'm done. Elliott_RBLX 15 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

RemoteFunctions return a value, RemoteEvents are a signal from server to client, client to server.

--LocalScript in a tool
local plr = game.Players.LocalPlayer
local stamp = script.Parent
local mouse = plr:GetMouse()
local event = game.ReplicatedStorage:WaitForChild("EventNameHere")

stamp.Activated:Connect(function()
    local mouse_pos = mouse.Hit.p -- mouse.Hit is a CFrame
    local selected --Assign selected to something
    event:FireServer(mouse_pos, selected)
end)

--In a ServerScript
local event = game.ReplicatedStorage:WaitForChild("EventNameHere")

event.OnServerEvent:Connect(function(plr, position, modelName)
    local object = game.ReplicatedStorage:FindFirstChild(ModelName)
    if object then
        object = object:Clone()
        object.MainPart.Position = position --Assign a MainPart to the model instance, weld all parts inside the model to the main part
    end
end)

Ad
Log in to vote
0
Answered by
Txeer 46
4 years ago

The only way I know are remote events. They seem a little confusing but here is the gist of them:

So our remote event, "createPart", will be stored in ReplicatedStorage. All we need to do is set up a listener for when the event fires:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

ReplicatedStorage.createPart.OnServerEvent:Connnect(function(plr, partToBeCreated)

    local ws = game.Workspace
    local part = Instance.new(partToBeCreated)
    part.Parent = ws

end)

Now when we fire the event, that piece of code will run. To make the event fire, we do this:

local tool = script.Parent

tool.Activated:Connect(function()

    game.ReplicatedStorage.createPart:FireServer("Part")

end)

Now when our player clicks with the tool out, our remote event will fire using FireServer.

Log in to vote
-1
Answered by 4 years ago

If you haven't seen my comment, do so now. Anyways, if you need help with remote events and remote functions, here are roblox API refferences on those:

https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

https://developer.roblox.com/en-us/api-reference/class/RemoteEvent

https://developer.roblox.com/en-us/api-reference/class/RemoteFunction

take that script for the block placement and put it inside ServerScriptService in a SERVER script, NOT a LOCAL script.

put a Remote Event in ReplicatedStorage

make a value for the type of the block that is selected (can be a name) inside of a value in the gui

put all the actual blocks in a folder in server storage

LOCAL SCRIPT or something along the lines of this:

mouse clicked

local typeOfBlock = (the selected block) local mouse.Target.Position

game.ReplicatedStorage.Event:FireServer(typeOfBlock, mousePos)

SERVER SCRIPT

game.ReplicatedStorage.Event.OnServerEvent:Connect(function(typeOFBlock, mousePos) --placement script goes here end)

hope that helps how to go about this, I normally dont do scripting to answer peoples questions because I dont think people learn how to script by copy and pasting, and I don't always have enough details to help you with the actual scripting and variables and such. I hope you actually LEARN from this! Hope this helps!

0
Would it be better to put it in ServerStorage rather than ReplicatedStorage? What difference does it make? Elliott_RBLX 15 — 4y

Answer this question