How would I clone a local script from replicated storage into player scripts when I activate a proximity prompt.
In proximity promt
script.Parent.Triggered:Connect(function(Player)
script.Parent.Parent.Parent.Parent.Value.Value = true
print("true")
game.ReplicatedStorage.HouseBuyCutscene.next:FireClient(Player)
end)
In local script in server storage
game.ReplicatedStorage.HouseBuyCutscene.next.OnClientEvent:Connect(function(player)
local camera = game.ReplicatedStorage.HouseBuyCutscene.Camera:Clone()
camera.Parent = player.PlayerScripts
local Cutscene = game.ReplicatedStorage.HouseBuyCutscene.Animation:Clone()
Cutscene.Parent = player.PlayerScripts
end)
2 Likes
So is the LocalScript in ServerStorage or in ReplicatedStorage?
2 Likes
Replicated storage (charlimit)
1 Like
reztcHH
(popshot)
July 7, 2023, 11:22pm
#4
local script in server storage ???
1 Like
reztcHH
(popshot)
July 7, 2023, 11:22pm
#5
why i think you only need change parent localscript
reztcHH
(popshot)
July 7, 2023, 11:25pm
#6
replicatedstorage is accessible from server/client
serverstorage is only accessible from the server and repositories are generally not suitable for placing scripts
modulescript is an exception
you can even put this code in startergui or starterplayerscripts
1 Like
I will assume the name of the script is “HouseBuyCutscene”
script.Parent.Triggered:Connect(function(Player)
script.Parent.Parent.Parent.Parent.Value.Value = true
print("true")
local Player = game.Players.LocalPlayer
local Cutscene = game.ReplicatedStorage.HouseBuyCutscene
-- Cloning the script
local Script = Cutscene:clone()
Script.Parent = Player.PlayerScripts
game.ReplicatedStorage.HouseBuyCutscene.next:FireClient(Player)
end)
try that
1 Like
This still doesn’t work. it says " Workspace.Buy/door.Buy.Part.ProximityPrompt.Script:9: attempt to index nil with ‘PlayerScripts’"