I have a system of luck boost that appear in the map if you didn’t take it so it appears I see it only in the client but with
the proximityprompt is not working, it is working only if the model is not cloned
this is my proximity prompt script
local RS = game:GetService("ReplicatedStorage")
local spawnLocation = script.Parent.Parent.Spawnpoint.Value
local function trigger(instance)
print(instance)
local main = instance.Parent
instance.Triggered:Connect(function(plr)
print(plr)
local BoostF = plr.Boosts
if BoostF then
local potion = BoostF:FindFirstChild(script.Parent.Parent.Name)
print(potion)
if potion then
--local luckboost = plr.LuckBoostTaken:FindFirstChild(spawnLocation)
--print(luckboost)
--if luckboost then
potion.Value += 1
--luckboost.Value = true
main:Destroy()
--end
--RS.Remotes.BoostNotTaken:FireServer(potion, luckboost)
RS.Remotes.StoreBoost:FireClient(plr, potion.Name)
end
end
end)
end
trigger(script.Parent)
this is my clone in local
local RS = game:GetService("ReplicatedStorage")
local SpawnPoints = workspace.GAME.SPAWNPOINTS
local CollFolder = workspace.Collectibles
wait(2)
RS.Remotes.BoostNotTaken.OnClientEvent:Connect(function(SpawnName)
for _, spawnpoints in pairs(SpawnPoints:GetChildren()) do
if spawnpoints.Name == SpawnName.Name then
if spawnpoints.BoostType.Value == "BasicLuckBoost" then
local BoostNotTaken = RS.Collectibles.BasicLuckBoost:Clone()
BoostNotTaken.Parent = CollFolder
BoostNotTaken.Spawnpoint.Value = spawnpoints.Name
BoostNotTaken:SetPrimaryPartCFrame(spawnpoints.CFrame)
elseif spawnpoints.BoostType.Value == "MediumLuckBoost" then
local BoostNotTaken = RS.Collectibles.MediumLuckBoost:Clone()
BoostNotTaken.Parent = CollFolder
BoostNotTaken.Spawnpoint.Value = spawnpoints.Name
BoostNotTaken:SetPrimaryPartCFrame(spawnpoints.CFrame)
end
end
end
end)
Because client and server do not interact together by default.
In short, everything that is created by a local script can only be saw and interacted with a local script… so you have to do the clone in server side.
No, I want the potion in local, if they didn’t take it before the potion will spawn but for an other player if the player take the potion the potion will not spawn I need to make a local script
You can’t put a local script into the part, local script only work in StarterCharacterScript, StarterPlayerScripts, Replicated First and StarterGui.
So what you need to do is:
Add a Local Script inside StarterPlayerScripts
Add a Script in ServerScriptService
Add a new Remote Event into the ReplicatedStorage
Inside the Local Script, get your items that are into the workspace and do their prompt triggered function, then do RemoteEvent:FireServer(), destroy the item and clone a new one.
Inside the Script, do RemoteEvent.OnServerEvent:Connect(function(Player), then give the potion value to the player.
ok now that’s working but not working at the same time
this is my new script
local RS = game:GetService("ReplicatedStorage")
local CollF = workspace.Collectibles
local spawnLocation
wait(4)
local function trigger(instance)
local main = instance.Parent
instance.Triggered:Connect(function(plr)
local BoostF = plr.Boosts
print(BoostF)
if BoostF then
local potion = BoostF:FindFirstChild(main.Name)
print(potion)
if potion then
local luckboost = plr.LuckBoostTaken:FindFirstChild(spawnLocation)
print(luckboost)
if luckboost then
main:Destroy()
end
RS.Remotes.BoostNotTaken:FireServer(potion, luckboost)
RS.Remotes.StoreBoost:FireServer(plr, potion.Name)
end
end
end)
end
for _, part in pairs(CollF:GetChildren()) do
local prompt = part:FindFirstChild("ProximityPrompt")
if prompt then
spawnLocation = part.Spawnpoint.Value
trigger(prompt)
end
end
but for the spawnlocation value that is not the good location how can I say the good value ?
You also need to add a ChildAdded connection to handle the prompt of the new cloned collectibles.
local RS = game:GetService("ReplicatedStorage")
local CollF = workspace.Collectibles
local function trigger(instance, spawnLocation)
local main = instance.Parent
instance.Triggered:Connect(function(plr)
local BoostF = plr.Boosts
print(BoostF)
if BoostF then
local potion = BoostF:FindFirstChild(main.Name)
print(potion)
if potion then
local luckboost = plr.LuckBoostTaken:FindFirstChild(spawnLocation)
print(luckboost)
if luckboost then
main:Destroy()
end
RS.Remotes.BoostNotTaken:FireServer(potion, luckboost)
RS.Remotes.StoreBoost:FireServer(plr, potion.Name)
end
end
end)
end
for _, part in pairs(CollF:GetChildren()) do
local prompt = part:FindFirstChild("ProximityPrompt")
if prompt then
trigger(prompt, part.Spawnpoint.Value)
end
end