Ive been trying to make it where a certain part will be cloned for when a player joins the game. Then when that player interacts with another part, the cloned part will change size only on that players screen. For example im trying to make it where when a player touches a part, lava will slowly rise on that players screen.
Here is the script im using -
local Lava = game.ReplicatedStorage.Lava:Clone()
Lava.Parent = game.workspace.CurrentCamera
local part = game.workspace.part
local function increaseHeight(Lava, amount)
Lava.Size += Vector3.new(0,amount,0)
Lava.CFrame *= CFrame.new(0,amount/2,0)
end
local function Move()
while true do
local w = wait()
increaseHeight(Lava, w)
end
end
end
part.Touched:Connect(function(touched)
if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
local Player = Players:GetPlayerFromCharacter(touched.Parent)
if Player then
if not debounce then
debounce = true
Move()
wait(1)
debounce = false
end
end
end
end)
Most of it works but the only problem is whenever a player touches the interaction part the cloned part rises on everyone’s screen instead of just the player who interacted with the part. Sorry if this is a little confusing, I’m trying my best to word it.
Player ones screen -
Player twos screen -
As you can see if player one touches the interaction part, the cloned part starts rising on each players screen. I only want it too rise on the person who interacts with the parts screen. If somebody could help that would be great, thanks.
local part = game.workspace.part
local RE = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
part.Touched:Connect(function(touched)
if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
local Player = Players:GetPlayerFromCharacter(touched.Parent)
if Player then
if not debounce then
debounce = true
RE:FireServer()
debounce = false
end
end
end
end)
ServerScriptService (script)
local RE = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local Lava = game.ReplicatedStorage.Lava:Clone()
Lava.Parent = game.workspace.CurrentCamera
RE:OnServerEvent:Connect(function()
local function increaseHeight(Lava, amount)
Lava.Size += Vector3.new(0,amount,0)
Lava.CFrame *= CFrame.new(0,amount/2,0)
end
local function Move()
while true do
local w = wait()
increaseHeight(Lava, w)
end
end
end
end)
Add a remote event in replicated storage.
Try Adding A Script to the part that a player is going to touch:
local deb = false
local event = game.ReplicatedStorage.RemoteEvent
script.Parent.Touched:Connect(function(touched)
local human = touched.Parent:FindFirstChildOfClass("Humanoid")
if human then
if deb == false then
deb = true
event:FireClient(game.Players[human.Parent.Name])
wait(1)
deb = false
end
end
end)
The local script in starterplayerscript:
local part = workspace.Part
local event = game.ReplicatedStorage.RemoteEvent
local Lava = game:GetService("ReplicatedStorage"):WaitForChild("Lava"):Clone()
Lava.Parent = workspace.CurrentCamera
local function increaseHeight(Lava, amount)
Lava.Size += Vector3.new(0,amount,0)
Lava.CFrame *= CFrame.new(0,amount/2,0)
end
local function Move()
while true do
local w = wait()
increaseHeight(Lava, w)
end
end
event.OnClientEvent:Connect(function()
Move()
end)