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

Local script not detecting hit function??

Asked by
Plieax 66
5 years ago
local this = game.Workspace.shop1.shopparts.detector
local db = false


this.Touched:connect(function(hit)
print "hit"
        if hit.Parent:FindFirstChild("Humanoid") ~= nil then
            print("hit")
            local char = hit.Parent
            local plr = game.Players:WaitForChild(char.Name)
            game.Workspace.CurrentCamera.CFrame = this.Parent.Parent.camparts.cam1.CFrame
            game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Fixed
        end
            end)

It will not even print hit for some reason. Can a local script allow detection of hits?

0
you might want to add the debounce parts right after "this.Touched:Connect(function(hit)" somewhat like: local debounce = true (drop line) this.Touched:Connect(function(hit) (drop line) if debounce == true then (drop line) debounce = false (put your code in) debounce = true (drop line) end (drop line) end) ALSO it needs to be in a server script, not local cruizer_snowman 117 — 5y

1 answer

Log in to vote
0
Answered by
yyyyyy09 246 Moderation Voter
5 years ago
Edited 5 years ago

Assuming you have Filtering Enabled on. Only server Scripts can recognize the Touched event, local scripts cannot.

Ad

Answer this question