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

How do you make it so that on touch a part will change the time?

Asked by 5 years ago

I have tried many times and have a script that just doesn't work

local part = script.Parent

part.Touched:Connect(function(hit)
print("Time part was touched by" .. hit.Name)
game.Lighting.ClockTime =14

What have I done wrong?

0
I'm sure that's a IP grabber link. Therefore, I won't click it. ^ Enbloxen 5 — 5y
0
That is stupid bro, that is a website designed to tell why i downvoted this question programmerHere 371 — 5y
0
kk Enbloxen 5 — 5y
View all comments (4 more)
0
Plus all sites you visit can see your IP anyways so why are you being so dramatic programmerHere 371 — 5y
0
IP Grabbers give people a certain persons IP, if they have a VPN on then they won't be able to see the true IP. If someone gets a real IP they can DDOS it and I don't like to trust dodgy-looking things. Enbloxen 5 — 5y
0
go tell that to everyone at stackoverflow.com who uses idownvotedbecau.se to tell people why they downvoted a question LOL. I don't see them being DDoS'd. Plus if tons of people use a website that does that, why would they specifically do something to you, ok last off topic comment programmerHere 371 — 5y
0
Nice, I thought it was so you never had to call me 'stupid'. I don't use Stack Overflow so leave. Enbloxen 5 — 5y

2 answers

Log in to vote
1
Answered by
nc2r 117
5 years ago
Edited 5 years ago

This a basic syntax error I highly suggest you open the output for debugging. Also format your code correctly

local part = script.Parent

part.Touched:Connect(function(hit)
    print("Time part was touched by" .. hit.Name)
    game.Lighting.ClockTime = 14
end) -- You need to end the function
0
You forgot a ) after end to close off the :Connect() call but this is better than the last answer programmerHere 371 — 5y
0
Count all the parenthesis again Connect accepts a callback argument so the closing parenthesis after end is the one you are talking about nc2r 117 — 4y
Ad
Log in to vote
-1
Answered by 5 years ago
local Players = game:GetService("Players")
local part

script.parent.Touched:Connect(function(part)

    local player = Players:GetPlayerFromCharacter(part.Parent)
    if not player then return end

    print("Time was changed by " .. player.Name)
    game.Lighting.ClockTime = math.random(23)
end)

Something like this.

0
-1 for no explanation programmerHere 371 — 5y

Answer this question