Hello, Matt! Isn’t it more logical to develop the part on the server and then communicate data from there to the client? Of course, you never know what the client might communicate to the server (security concerns). Could you also give a specific example of what you’re trying to attempt?
You can’t send Instances through remote events so this wouldn’t work.
Edit: You can’t send instances only on the client. You can send instances that exist on the server though.
I’ve got a character creation system, when you click a button that is a “Hair style” in this case. I store the hair model inside the button, and put the hair on in the server script. Atm the hair is just in the workspace. But I want to transfer the Hair to the button to keep everything neat, also I don’t know which button is pressed. Unless you can pass button data to the server?
So not a part, a part that has already been created
You’re better off storing your assets somewhere like ReplicatedStorage, and firing a remote with data (such as a string) that corresponds to that particular asset, e.g. assigning an ID to each hair asset and applying it on the server when the user selects it.
Pass the reference of the hair to the server, and then equip it on the server.
Oh That makes alot more Sense ! Try something like this (Beginner Example) :
local script:
local Event = game.ReplicatedStorage:WaitForChild("Event")
local Button = ("Refrence ur button")
local CurrentHair = nil
Button.MouseButton1Click:Connect(function()
CurrentHair = "01"
Event:FireServer(CurrentHair)
end)
script:
local Event = game.ReplicatedStorage:WaitForChild("Event")
local Character = nil
Event.OnServerEvent:Connect(function(player, Hair)
Character = player.Character or Player.CharacterAdded:Wait()
if Hair == "01" then
--- get the hair from somewhere and put it on the character
end
end)
Dunno if that is secure in anyway, however it does print. And I am able to click on the output with the given part
BUT This won’t work for created instances on the client (i believe?)
localscript:
game.ReplicatedStorage.RemoteEvent:FireServer(workspace.Baseplate)
server-script:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, part)
print(part, part.Name)
end)
Still doesn’t work. Like I said before, you can not send any instance through remote events.
you maybe didn’t understand me
local Event = game.ReplicatedStorage:WaitForChild("Event")
local Part = workspace.Part
Event:FireServer(Part)
Oh, sorry, yea I didn’t understand.
Would this be safe? What if client alters part and sends the altered part to server?
Are you able to tell me what is wrong here? I’m trying to attach a hat to my characters head in the workspace. This worked when I was using the remotefunction, but now changing to this method it’s no longer working. It creates the hat but it creates the hat on top at the origin and it just falls instead of attaching to the character. Any ideas?
local script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent1")
local Button = script.Parent
local styleType = {"Hair", "1"}
Button.MouseButton1Click:Connect(function()
Event:FireServer(styleType)
end)
server script:
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent1")
local Character = nil
local style = nil
local humanoid = nil
local char = workspace:WaitForChild("CharSelectDummy")
Event.OnServerEvent:Connect(function(player, styleType)
Character = player.Character or player.CharacterAdded:Wait()
humanoid = char:WaitForChild("Humanoid")
if styleType[1] == "Hair" then
-- Hair types
if (styleType[2] == "1") then
style = player.PlayerGui.CharCreationScreen.HairScrollingFrame.ViewportFrame1.Hair:Clone()
humanoid:AddAccessory(style)
end
end
end)
if the hat is an Accessory then just Parent it to the Character you want instead of using the AddAcesorry function. Also maybe create a folder in replicated will all your accessories and reference it from there instead of going all the way in the playergui.
You can, as long as that instance exists on both client and server. A part created on the client cant be sent to the server, and a part inside ServerStorage cant be sent to the client. An instance in Workspace being sent through a remote from the server would be received on the client.
But why isn’t this working?
Doesn’t AddAccessory just parent? Probably wont work I think
Yea didn’t work
-- Local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent1")
local Button = script.Parent
local styleType = {"Hair", "1"}
Button.MouseButton1Click:Connect(function()
Event:FireServer(styleType)
end)
--Server script
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent1")
local Character = nil
local style = nil
local humanoid = nil
local char = workspace:WaitForChild("CharSelectDummy")
Event.OnServerEvent:Connect(function(player, styleType)
Character = player.Character or player.CharacterAdded:Wait()
humanoid = char:WaitForChild("Humanoid")
if styleType[1] == "Hair" then
-- Hair types
if (styleType[2] == "1") then
style = player.PlayerGui.CharCreationScreen.HairScrollingFrame.ViewportFrame1.Hair:Clone()
style.Parent = char
end
end
end)
Can you show an example of the accessory in-studio + send a video of what it looks like when the script is run??
https://developer.roblox.com/en-us/api-reference/function/Humanoid/AddAccessory
Might be worth reading up on AddAccessory(), the BasePart instance named “Handle” inside the Accessory instance requires an Attachment instance inside of it matching the name of an Attachment instance inside the humanoid’s parent (character model), if these conditions are satisfied the BasePart instance is welded to the Attachment instance of the character model in such a way that both Attachment instances occupy the same space.