Hey there! So I’m trying to make a system in my game where if you find a present, then a door opens. Pretty simple, but I don’t know how to do this locally for one player. Whenever I have tried doing a script, it will just happen to all the players, which I don’t want. I will give more details if needed, thanks!
Usually you use a LocalScript
to do this
You need to destroy the part in a local script? If you’re running .Touched on the server, you can either use a remote event, or move it to the client.
I have tried that, but nothing happens. I’ll try once more though
I have tried using a remote event, that says Fire Client() , but it won’t work.
Oh wait I might know the issue
Put the door in ReplicatedStorage, and make a local script that clones it into the game. Then make another (or the same) local script with a present.Touched(function) and it should delete locally.
Can you specify a bit more, oof?
I will put the door in replicated storage now
you could just have a present.touched function in a localscript i believe deleting the door with :Destroy(), or making it transparent and cancollide off as jaxson stated so u can still keep it where it is, but just, different
I have tried that, but simply nothing will happen.
thats ez-
--// server code
local door = _path_to_door
local remote = game.ReplicatedStorage.DoorEvent
door.Touched:Connect(function(hit)
remote:FireClient()
end)
--// client code
local door = _path_to_door
local remote = game.ReplicatedStorage.DoorEvent
remote.OnClientEvent:Connect(function()
door.Parent = nil -- the people will complain to me about using :Remove() :sob:
end)
Server goes in serverscriptservice
Client in ReplicatedFirst
You can place the Door parts in the Players’ CurrentCamera
temporarily using a localscript
there, you can edit the visible properties of the door part without it effecting gameplay, place the localscript
in ReplicatedFirst
Do not destroy the part, instead, on the localscript
change the parts’ Transparency
value to 1
and set the CanCollide
bool to false
I’ll try that now, so what I’m trying to do is touching the christmas present will destroy the door, not touching the door and destroying it. I will just try to replace the door with my present variable though
local Present = -- path to present here
local Door = -- path to door here
Present.Touched:Connect(function()
Door:Destroy()
end)
create a local script, put this code in the localscript then put the localscript in starterplayer
does this solve your problem?
( i know you said it didnt work before but it should work now if this isnt what you did in the script)
I have decided to try something else to solve my issue, thank you guys so much for trying to help me, I appreciate it!
In a localscript:
workspace.Present.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") then
workspace.Door:Destroy()
end
end)