I dont need to show just let me say there is some maps in ServerStorage.Maps.(folder), and every 70 secs one model go to workspace and the one was there get back to his place
For testing purposes, would it be easier to change the 70 second delay to 10 seconds?
Are you able to send a screenshot of the explorer tab when the map is in workspace?
Is HalloweenDropperDone a touchable part?
yeaâŚ
(max charrrrrrrrrrrrrrrr)
So is the point of the script that you want to send a RemoteEvent when the player touches a specific part in this map?
yesâŚ
(max charrrrrrrrrrrrrrrr)
If this is the case, it may be better to use a server script.
For example,
local players = game.Players
game.Workspace.HalloweenDropper.StuffAtHalloweenLobby.HalloweenDropperDone.Touched:Connect(function(hit)
local player = players:FindFirstChild(hit.Parent.Name)
if player then
end
end)
Iâm still not quite sure on exactly what you want, but hopefully that helps. The benefit of a server-script is you donât need to send a RemoteEvent to the server.
dont work
{max charrrrrrrrrrrr{
Are you able to elaborate what doesnât work?
I did for example Print(âwegwsegâ) and its didnât show
Here. Iâve got 2 ways you can do this. I have explained everything in the script.
Number 1.
Script in ServerScriptService:
local Players = game:GetService("Players") -- getting players
local PartTrigger = game.Workspace.TouchedPart -- change this to whatever your part is called
local cooldown = false -- if you want a cooldown for your part
function touched(hit) -- hit
if hit.Parent ~= nil then -- making sure that the part that touched has a character as its parent
local player = Players:GetPlayerFromCharacter(hit.Parent) -- getting the player from the character that hit the part
if player and not cooldown then -- "not cooldown" is same as "cooldown == false"
cooldown = true
print("touched") -- put your code here
wait(0.1)
cooldown = false
elseif cooldown then -- "if cooldown" is the same as cooldown == true
print("still on cooldown")
end
end
end
PartTrigger.Touched:Connect(touched) -- will connect function when part is touched
Number 2.
You said you wanted a remoteEvent to fire when touched the part. So ill do that too.
Local script in StarterCharacterScripts:
local RemoteEvent = game.ReplicatedStorage:WaitForChild("Touched") -- change this to whatever your remote event is called
function touched()
RemoteEvent:FireServer() --firing server
end
game.Workspace.TouchedPart.Touched:Connect(touched) -- change this to wherever your part is
Add a script in ServerScriptService:
local RemoteEvent = game.ReplicatedStorage:WaitForChild("Touched") -- same thing. make this your event name
local cooldown = false
RemoteEvent.OnServerEvent:Connect(function(plr) -- you can keep the "plr" in if you want to change things for the player
if not cooldown then
cooldown = true
print("touched")
wait(0.1)
cooldown = false
elseif cooldown then
print("cooldown")
end
end)
There are both ways I can do this for you. If you dont want to use any of these ways, well, I donât know what to tell you.
how to do it with Value?
(Number 2)
local RemoteEvent = game.ReplicatedStorage:WaitForChild("Touched") -- change this to whatever your remote event is called
local TimePlayed = ... -- replace "..." with your value
local cooldown = false
function touched()
if TimePlayed.Value <= 300 and not cooldown then
cooldown = true
RemoteEvent:FireServer() --firing server
wait(1)
cooldown = false
else
print("no") -- dont do anything if they dont have <=300 "timeplayed"
end
end
end
game.Workspace.TouchedPart.Touched:Connect(touched) -- change this to wherever your part is
local RemoteEvent = ... -- your remote event
local TimePlayed = ... -- Replace this with your value
TimePlayed.Changed:Connect(function() -- you can also use TimePlayed:GetPropertyChangedSignal("Value"):Connect(function()
if TimePlayed.Value <= 300 then
RemoteEvent:FireServer() --firing server
end
end
its not automatic
max charrrrrr
Put it in StarterCharacterScripts. It should be automatic
For people that dont know, he wanted to fire a server inside of a local script. But he also tried to get the service SeverStorage from a local script.
You are unable to get ServerStorage from a local script.
Hope this helps for anyone reading this
I think I understand your issue now.
If youâre occasionally adding models into the workspace folder and detecting for touch, I would recommend you to use workspace.ChildAdded
instead, then connect it to a touched event.
The code would look something like this:
local RS = game:GetService("ReplicatedStorage")
local Plrs = game:GetService("Players")
local RE = RS:WaitForChild("FirstQuest")
local Plr = Plrs.LocalPlayer
workspace.ChildAdded:Connect(function(NewPart)
if NewPart.Name == "HalloweenDropper" then
local Pat = NewPart.StuffAtHalloweenLobby.HalloweenDropperDone
Pat.Touched:Connect(function(Hit)
local Target = Hit.Parent
local TouchedPlr = Plrs:GetPlayerFromCharacter(Target)
if TouchedPlr and TouchedPlr == Plr then
RE:FireServer() -- This will send a request from the client to the server
end
end)
end
end)
We already discussed the issue inside of private messages. The reason why he was getting infinite yield is because he was trying to access serverstorage from a local script. (Also I gave him countless codes that WORKED.)