Log in to vote

My code is calling a function before the trigger does?

Asked by 1 month ago
Edited 1 month ago

It's very confusing and only yesterday it was working fine.

local functionblock3 = game.workspace.FunctionBlock3
local AppearingBlock = game.workspace.AppearingBlock

    local functionblock3 = "functionblock3 in use"
    print (functionblock3)
    AppearingBlock.Transparency = 0
    AppearingBlock.Cancollide = true

The one I just copy and pasted is meant to call a function when the player touches a block, however when I test my game, the function is already called.

 local FunctionBlock2 = game.workspace.FunctionBlock2
local DissapearingBlock = game.workspace.DissapearingBlock

    local functionblock = 'function block touched'
    print (functionblock)
    DissapearingBlock.Transparency = 1
    DissapearingBlock.Cancollide = false

This code calls a function when my character touches a block, again, it worked fine just yesterday but the function calls before I even step on the block.

1 answer

Log in to vote
Answered by
Xapelize 1459 Moderation Voter
1 month ago

Because your not touching a part but "SOMEONE" else does, its not a player, its a part!!!!!!!! detecting if theres humanoid and fire it to fix

like putting an if player:FindFirstChild("Humanoid") then in line 2

also if u want to get the player parameter use game.Players.PlayerAdded:Connect(function(player) end) Xapelize 1459 — 1mo
Xapelize, it turns out it was touching the baseplate, it's quite strange because yesterday the part was on the baseplate too. nafey200 52 — 1mo
it is probably the part was unanchored so it touched Xapelize 1459 — 1mo

Answer this question