Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Raycast stops working after a while?

Asked by 5 years ago
01local area
02 
03game.Players.PlayerAdded:Connect(function(plr)
04    plr.CharacterAdded:Connect(function(chr)
05        local HumanoidRP = chr:WaitForChild("HumanoidRootPart")
06        while wait(0.1) do
07            local newRay = Ray.new(HumanoidRP.CFrame.p, Vector3.new(0,-1,0).unit * 10)
08            local Hit = game:GetService("Workspace"):FindPartOnRay(newRay, chr)
09            if Hit then
10                shared.hitPart = Hit.Name
11            end
12            if shared.hitPart == "ShipTeleportPad" then
13                game.ReplicatedStorage.TeleportOn:FireClient(plr)
14            else
15                game.ReplicatedStorage.TeleportOff:FireClient(plr)
View all 35 lines...

What this does is it uses a raycast from the player down to see what part they are standing on. The first if which senses for ShipTeleportPad brings up a gui to teleport to the desert. This comes up when you step on it, and you can teleport to the desert. THe next senses if your touching the desert baseplate, and if you are, then it will fire an event that will change the music and skybox. The third if statement senses if you touch the lobby floor, which will fire an event that changes the skybox and the music. When you join, lobby works fine. When you teleport, desert works fine. But when you teleport from the desert back to the lobby, the raycast stops working entirely, not changing the music or skybox back, and not opening the teleport gui. Can somebody help me?

0
Use a loop JesseSong 3916 — 5y
0
I did it says while area == "desert" do Swaggyguy229 7 — 5y
0
also, you see the print(area) in the lobby part section? It prints lobby when you spawn, but after going to the desert it doesn't print at all. Swaggyguy229 7 — 5y

Answer this question