Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Why Wont It Change Colors When Touched?

Asked by 12 days ago
local function onTouch(hit)

    game.Workspace.Part.BrickColor = BrickColor.new("Mid gray")
end

No errors?

0
Also make sure it is in a server script. JesseSong 3371 — 12d

1 answer

Log in to vote
0
Answered by
JesseSong 3371 Moderation Voter Community Moderator
12 days ago
Edited 12 days ago

Simple answer is that there's no touched event you also forgot to call your function :onTouch() A simple solution would be this:

local part = script.Parent
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
part.BrickColor = BrickColor.new("Mid gray")
end
end)
0
it didnt work error15:54:25.647 - Workspace.Part.Script:6: Expected 'end' (to close 'function' at line 2), got <eof>; did you forget to close 'then' at line 3? JordanTheDev_Team 31 — 12d
0
edited try again. JesseSong 3371 — 12d
Ad

Answer this question