Touch script help

why doesn’t work. i don’t have any errors.

can you post the code without image?

1 Like

local fastwork = false

game.ServerStorage.Worlds.World1:Clone().Parent = workspace.ScreenWorld

game:GetService(“ReplicatedStorage”).RemoveItem.OnServerEvent:Connect(function(plr, item)
local a = game.ReplicatedFirst:WaitForChild(item.Name)
if a then
local e = a:Clone()
e.Parent = plr.Backpack
end
item:Destroy()
end)

workspace.ScreenWorld.DescendantAdded:Connect(function()
print(“test”)
wait(1)
for a,b in pairs(workspace.ScreenWorld:GetChildren()) do
local items = b.UsableItems

	spawn(function()
		for a,b in pairs(items:GetChildren()) do
			b.ClickDetector.MouseClick:Connect(function()
				if not fastwork then
					if b:WaitForChild("CinematicCamera").Value == true then
						fastwork = true
						game:GetService("ReplicatedStorage").ChangeCameraType:FireAllClients("Cinematic", b.Name, b:WaitForChild("CinematicCamera"):WaitForChild("Dialog").Value, b:WaitForChild("CinematicCamera"):WaitForChild("Duration").Value)
						wait(7)
						fastwork = false
					end			
				end
			end)
		end
	end)
	
	
	b.SkipWorld.Touched:Connect(function(hit)
		print("sa")
		if hit and hit.Parent then
			local plrrr = game.Players[hit.Parent]
			if plrrr then
				print(string.sub(b.Name, 5))
				game.Workspace.ScreenWorld.World1.Parent = game.ServerStorage.Worlds
				wait()
				game.ServerStorage.Worlds.World2.Parent = game.Workspace.ScreenWorld
				wait()
				plrrr:Respawn()
			end
		end
	end)
end	

end)

game.Players:FindFirstChild(hit.Parent.Name)
Also abundant checks as touched always return you something that isnt nil and will always have parent.

Would be better if you use

local plrrr = game.Players:GetPlayerFromCharacter(hit:FindFirstAncestorOfClass("Model"))

This is only because the hit parameter’s first parent isn’t always the character model (for example, it could be a hat object)

Depends on what truly counts as hitbox at that point.

thanks its worked and thanks for looked my script