mouse.Target isn't replicated across the server/client boundary so I can't for example, make it so that a specific model that I am pointing at becomes a color when you click it (by using a remote function)
is there any way to go around this?
mouse.Target isn't replicated across the server/client boundary so I can't for example, make it so that a specific model that I am pointing at becomes a color when you click it (by using a remote function)
is there any way to go around this?
You can do this using remote events:
The normal script inside ServerScriptService:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ColorEvent = ReplicatedStorage:WaitForChild("ColorEvent")
ColorEvent.OnServerEvent:Connect(function(Player,Target)
if Target then
Target.BrickColor = BrickColor.new("Really red")
end
end)
The local script inside PlayerGui:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ColorEvent = ReplicatedStorage:WaitForChild("ColorEvent")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.Button1Down:Connect(function()
if Mouse.Target and Mouse.Target.Parent then
local Target = Mouse.Target
ColorEvent:FireServer(Target)
end
end)
And create an event called ColorEvent inside ReplicatedStorage
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
You CAN make it so that when you click on a model, all of its parts become a specific color(by using a RemoteFunction/RemoteEvent).